EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   Automatic server restart using task manager (https://www.eqemulator.org/forums/showthread.php?t=41458)

Fridgecritter 07-28-2017 11:30 PM

Automatic server restart using task manager
 
I am using Server 2016 and I need to accomplish a few things automatically every 6 hours:

Shut down the server
Run two queries on the database one at a time (they run quick)
Bring the server back up

So I tried using the windows task scheduler, made two batch files, one for each query I needed to run, and then made 4 scheduled tasks...

6PM take down server (calls t_server_stop.bat)

6:01 Run query1 (calls to a batch file that runs mysql --user=root --password=mypass peq < c:\query1.sql)

6:02 Run query2 (calls to a batch file that runs mysql --user=root --password=mypass peq < c:\query2.sql)

6:03 Bring server back up (calls t_server_start.bat)

But for some reason it brings the server down, runs the two batch files but doesn't bring the server back up. And I set the tasks to be run even if the user isn't logged on, and run with admin privileges)

So, I'm thinking of consolidating it all into one batch file, but I don't know how to do that. Once it logs into the mysql prompt, dos commands like sleep, etc... don't work. Can someone school me and teach me something about creating a batch file to call a combination of dos commands and mysql commands, so I can have task scheduler call one batch file and be done with it? Thanks a ton in advance.

Andercross 07-29-2017 03:28 PM

Can you post the contents of the 2nd batch file (bring server up)? I'm more of a RHEL guy, but I do manage some windows servers and work in Powershell - I might be able to help!

Thanks for the server by the way, have been enjoying myself!

-Kapow

Fridgecritter 07-29-2017 04:28 PM

The batch file is the stock one that comes with Akka's installer. I didn't create it.
Code:

@echo off
cls
echo *** CLEARING OLD LOGS ***
del "logs/zone/" /q
shared_memory.exe
start perl win_server_launcher.pl zones="30" zone_background_start kill_all_on_start
exit


Fridgecritter 07-29-2017 04:28 PM

And glad you're enjoying the server. It's been a challenge.

Scorpious2k 07-29-2017 04:58 PM

timeout /t [#seconds]

Might be what you are looking for, I use it in my startups.

Andercross 07-29-2017 04:58 PM

I've never set up an emu server, maybe the server shutdown isn't completed by the time that you start it up again? Some background process? Unless the kill_all_on_start arg in the perl script wipes everything that could be remnant?

Fridgecritter 07-29-2017 05:24 PM

I figured it out with the help of timeout /t [5 seconds]

AND the most important thing after taking the "exit" off the end of my batch file, I could see why it was not starting the server back up. For perl to find world.exe, etc... the batch file has to be ran from the EQEmuServer folder because in the perl file it doesn't pass a specific directory argument. It was running from desktop before.

So for other people's information, here's what my end result looks like in a batch file:

Code:

taskkill /IM perl.exe /F
taskkill /IM queryserv.exe /F
taskkill /IM ucs.exe /F
taskkill /IM eqlaunch.exe /F
taskkill /IM Zone.exe /F
taskkill /IM world.exe /F
taskkill /IM shared_memory.exe /F
taskkill /IM loginserver.exe /F

timeout /t 3

mysql --user=root --password=mypass peq < c:\query1.sql

timeout /t 5

mysql --user=root --password=mypass peq < c:\query2.sql

timeout /t 5

@echo off
cls
echo *** CLEARING OLD LOGS ***
del "logs/zone/" /q
shared_memory.exe
start perl C:\EQEmuServer\win_server_launcher.pl zones="30" zone_background_start kill_all_on_start
exit

So now all I have to do is create 4 tasks, one for every 6 hours, and it will run that each time. Tested and it works. Thanks a ton Scorpious.

Scorpious2k 07-30-2017 09:28 AM

You're welcome.

Always glad to help.

Fridgecritter 07-30-2017 10:59 AM

One more thing... I got up this morning and the server was down. I checked the task manager and realized I didn't check a box that says "Start in" and put in each task C:\EQEmuServer

Super important or the task manager will run everything from \system32 I think. We'll see how it goes at the next restart at noon.

Fridgecritter 07-30-2017 12:08 PM

It's working! The only thing is, the dos prompt windows don't pop up, and everything runs in the background.


All times are GMT -4. The time now is 01:43 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.