Scripting your multi-server server
Posted: Tue Dec 09, 2014 12:16 pm
So you want to house multiple servers. Maintenance can be challenging enough on a single, but keeping multiple up to date can be a real challenge. Being a one man team for maintenance on my server, the ability to react quickly is critical. For this reason I've developed a few methodologies and scripts that assist in keeping things manageable.
First, there is sql structure. I have an excel spreadsheet attached that will generate your update script. Just put in the correct corresponding IP's and ports, and it will do the rest of the work for you. Create a new document in your sql directory called zz_zonesettings.sql, and paste the sql generated in the work sheet into it. That will ensure that, after you load your sql into the database, it will execute last and update your settings.
Second, you have data structure. I have found that having one central repo server is the most effective. Pulls and compiling occurs there, and nothing else. I use c:\repo\ that keeps a master repository of all the data, including custom information you have. Then, I have the production folder, at c:\prod\ that contains the executables. This allows me to update and compile repo without affecting running servers. The goal is to minimize down time.
Third, you have server structure. How many servers you have is up to you. For this instance I'm using 5. First, you have the lobby server. The lobby server houses the repo that gets updated, and runs the lobby/chat server, search server, and unmanned zones. Then, I have City, Outside, Dungeon, and Endgame. This is in an effort to isolate crashes. You could combine outside and dungeon if you want. I recommend keeping endgame isolated as this is where crashes seem to occur most frequently.
Forth, you have maintenance structure. I have a total of 3 scripts that completely automate the update process. After you do your pull, you need to compile the new information as well as load the new sql.
First, we'll clean and build the applications:
Then we'll load the SQL. This can be done while you're rebuilding. Make sure you scrub out the player data, or you'll be starting new every time:
The compiling can be done while servers are running. SQL, I would take them down first.
Once you're done, you need to distribute the new software. First we'll start with the batch script for the lobby:
The ping function is used as a wait command to kill the applications. I have shortcuts to the servers in the root of the c: drive which has the arguments necessary.
This will kill, copy, and restart lobby, search, and game server.
For the regional servers, you'll want to use a script like this:
Again, ping is a wait command, then delete the old production data and copy in the new, then restart the game server.
The game server shortcut in your c: will have specific arguments to bind to the correct address and port:
c:\prod\DSGame-server.exe --ip externalip --port 54245
This is what I use for my unused zones. This port must match the port forwarded from your router.
IE your router forwards 54240 to 10.0.0.221, then server with 10.0.0.221 would use --port 54240 on the end of the shortcut to start the game server on that server.
First, there is sql structure. I have an excel spreadsheet attached that will generate your update script. Just put in the correct corresponding IP's and ports, and it will do the rest of the work for you. Create a new document in your sql directory called zz_zonesettings.sql, and paste the sql generated in the work sheet into it. That will ensure that, after you load your sql into the database, it will execute last and update your settings.
Second, you have data structure. I have found that having one central repo server is the most effective. Pulls and compiling occurs there, and nothing else. I use c:\repo\ that keeps a master repository of all the data, including custom information you have. Then, I have the production folder, at c:\prod\ that contains the executables. This allows me to update and compile repo without affecting running servers. The goal is to minimize down time.
Third, you have server structure. How many servers you have is up to you. For this instance I'm using 5. First, you have the lobby server. The lobby server houses the repo that gets updated, and runs the lobby/chat server, search server, and unmanned zones. Then, I have City, Outside, Dungeon, and Endgame. This is in an effort to isolate crashes. You could combine outside and dungeon if you want. I recommend keeping endgame isolated as this is where crashes seem to occur most frequently.
Forth, you have maintenance structure. I have a total of 3 scripts that completely automate the update process. After you do your pull, you need to compile the new information as well as load the new sql.
First, we'll clean and build the applications:
Code: Select all
cd c:\program files (x86)\msbuild\12.0\bin
msbuild "c:\repo\win32\dssearch-server\dssearch-server.sln" /t:clean
msbuild "c:\repo\win32\dssearch-server\dssearch-server.sln" /t:build
msbuild "c:\repo\win32\dsconnect-server\dsconnect-server.sln" /t:clean
msbuild "c:\repo\win32\dsconnect-server\dsconnect-server.sln" /t:build
msbuild "c:\repo\win32\dsgame-server\dsgame-server.sln" /t:clean
msbuild "c:\repo\win32\dsgame-server\dsgame-server.sln" /t:build
Code: Select all
cd c:\repo\sql
del auction_house.sql
del chars.sql
del accounts.sql
del char_effects.sql
del char_equip.sql
del char_exp.sql
del char_inventory.sql
del char_jobs.sql
del char_look.sql
del char_pet.sql
del char_pet_name.sql
del char_points.sql
del char_profile.sql
del char_skills.sql
del char_stats.sql
del char_storage.sql
del char_vars.sql
del char_weapon_skill_points.sql
del conquest_system.sql
del delivery_box.sql
del linkshells.sql
FOR %%X IN (*.sql) DO ECHO Importing %%X & "c:\pathtomysqlexe\mysql" databasename -h databaseip -u username -ppassword < %%X
Once you're done, you need to distribute the new software. First we'll start with the batch script for the lobby:
Code: Select all
taskkill /f /im dsconnect-server.exe
taskkill /f /im dssearch-server.exe
taskkill /f /im dsgame-server.exe
ping 10.0.0.1
rmdir c:\prod /s /q
mkdir c:\prod
xcopy c:\repo\* c:\prod\ /s /i
start c:\connect.lnk
start c:\search.lnk
start c:\game.lnk
This will kill, copy, and restart lobby, search, and game server.
For the regional servers, you'll want to use a script like this:
Code: Select all
taskkill /f /im dsgame-server.exe
ping 10.0.0.1
rmdir c:\prod /s /q
mkdir c:\prod
xcopy \\lobby\repo\* c:\prod\ /s /i
start c:\game.lnk
The game server shortcut in your c: will have specific arguments to bind to the correct address and port:
c:\prod\DSGame-server.exe --ip externalip --port 54245
This is what I use for my unused zones. This port must match the port forwarded from your router.
IE your router forwards 54240 to 10.0.0.221, then server with 10.0.0.221 would use --port 54240 on the end of the shortcut to start the game server on that server.