Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2017, 11:30 PM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default 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.
Reply With Quote
  #2  
Old 07-29-2017, 03:28 PM
Andercross
Fire Beetle
 
Join Date: Jun 2009
Location: Florida atm
Posts: 7
Default

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
Reply With Quote
  #3  
Old 07-29-2017, 04:28 PM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default

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
Reply With Quote
  #4  
Old 07-29-2017, 04:28 PM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default

And glad you're enjoying the server. It's been a challenge.
Reply With Quote
  #5  
Old 07-29-2017, 04:58 PM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default

timeout /t [#seconds]

Might be what you are looking for, I use it in my startups.
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #6  
Old 07-29-2017, 04:58 PM
Andercross
Fire Beetle
 
Join Date: Jun 2009
Location: Florida atm
Posts: 7
Default

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?
Reply With Quote
  #7  
Old 07-29-2017, 05:24 PM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default

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.
Reply With Quote
  #8  
Old 07-30-2017, 09:28 AM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default

You're welcome.

Always glad to help.
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #9  
Old 07-30-2017, 10:59 AM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default

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.
Reply With Quote
  #10  
Old 07-30-2017, 12:08 PM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:04 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3