EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Tools (https://www.eqemulator.org/forums/forumdisplay.php?f=593)
-   -   Auto Restarts of Server (https://www.eqemulator.org/forums/showthread.php?t=36190)

blindaviator 12-31-2012 05:31 PM

Auto Restarts of Server
 
Don't know if this program is known here but I have this setup on my system and it works great.

FireDaemon Pro can setup any program (including command line starts) as a system service for automatic restarts. I have this setup on my server machine to restart any of the 5 services required for the server to run (so far my login server has crashed once and it restarted it within 1 minute and was back online). Program cost is $50 US but IMHO that is cheap for automatic restarts and no minimized command windows to accidentally close. You can download a 30 day trial of it and see if it is to your liking.

Also you can download their program FireDaemon Fusion which gives you a web based interface for access to running services. I give access to this for a trusted friend to restart the server remotely when updating the database. Best parts about this program is it is FREE and it does not require FireDaemon Pro to run.

Don't know if external links are allowed here but the programs are easy enough to find in a google search.

c0ncrete 12-31-2012 10:08 PM

you could also put this in your EQEmu server directory and run it for free

runserver.vbs
Code:

set Shell = CreateObject("WScript.Shell")

' list of executables
procList = array("EQEmuLoginServer", "World", "EQLaunch", "UCS")

sub RunServer
    for each process in procList
        if not Running(process) then
            runStr = process & ".exe"
            if StrComp("EQLaunch", process, 1)=0 then
                runStr = runStr & " zone"
            end if
            'WScript.Echo "running " & runStr
            Shell.Run runStr, 0, false
        end if
    next
end sub

' is process running?
function Running(procName)
    found = false
    'WScript.Echo "checking " & procName
    for each proc in GetObject("Winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE name='" & procName & ".exe'")
        if StrComp(proc.name, procName, 1) then
            found = true
            exit for
        end if
    next
    Running = found
end function

do until 0
    RunServer
    ' 30 second delay
    Wscript.Sleep 30000
loop

remove EQEmuLoginServer from the procList if you're not running your own login server and change value of sleep to change how long it takes between checks (in milliseconds).

you'll need to end the process named wscript.exe to stop the script as it won't have a command prompt.

i'd probably add some sort of logging method for restarts, but i got bored with it.

wolfwalkereci 12-31-2012 11:17 PM

Yeah I run a batch script and use winblows task scheduler to back that script up with another in case it fails.

c0ncrete 01-01-2013 12:15 AM

i just can't help myself...

added functionality that makes certain you don't end up running multiple instances of the same script accidentally (very bad things would have happened).

runemu.vbs
Code:

set Shell = CreateObject("WScript.Shell")

' return process object collection where process name starts with procName
function ProcessObjectList(procName)
    queryStr = "SELECT * FROM Win32_Process WHERE name LIKE '" & procName & "%'"
    set ProcessObjectList = GetObject("Winmgmts:").ExecQuery(queryStr)
end function

' is process running?
function Running(procName)
    if ProcessObjectList(procName).Count < 1 then
        Running = false
    else
        Running = true
    end if
end function

' start processes if not already running
sub RunServer
    for each procName in array("EQEmuLoginServer", "World", "EQLaunch", "UCS")
        if not Running(procName) then
            runStr = procName & ".exe"
            if StrComp("EQLaunch", procName, 1)=0 then
                runStr = runStr & " zone"
            end if
            Shell.Run runStr, 0, false
        end if
    next
end sub

' exit if this script is already running
set processList = ProcessObjectList("wscript")
if processList.Count > 1 then
    foundScript = 0
    for each process in processList
        if StrComp(process.name, "wscript.exe", 1)=0 then
            if InStr(process.CommandLine, WScript.ScriptName) then
                foundScript = foundScript+1
            end if
        end if
        if foundScript > 1 then
            WScript.Echo WScript.ScriptName & " is already running!"
            WScript.Quit
        end if
    next
end if
set processList = Nothing

' loop forever (30000 millisecond delay)
do while true
    RunServer
    Wscript.Sleep 30000
loop

this one terminates both the monitoring script and all running emulator executables

stopemu.vbs
Code:

set Shell = CreateObject("WScript.Shell")

' return process object collection where process name starts with procName
function ProcessObjectList(procName)
    queryStr = "SELECT * FROM Win32_Process WHERE name LIKE '" & procName & "%'"
    set ProcessObjectList = GetObject("Winmgmts:").ExecQuery(queryStr)
end function

' exit if this script is already running
set processList = ProcessObjectList("wscript")
if processList.Count > 1 then
    foundScript = 0
    for each proc in processList
        if StrComp(proc.name, "wscript.exe", 1)=0 then
            if InStr(proc.CommandLine, WScript.ScriptName) then
                foundScript = foundScript+1
            end if
        end if
        if foundScript > 1 then
            WScript.Echo WScript.ScriptName & " is already running!"
            WScript.Quit
        end if
    next
end if
set processList = Nothing

' terminate all instances of emulator monitoring script server processes
for each procName in array("WScript", "EQEmuLoginServer", "World", "EQLaunch", "UCS", "Zone")
    for each process in ProcessObjectList(procName)
        terminate = true
        if StrComp(process.name, "wscript.exe", 1)=0 then
            if InStr(process.CommandLine, "runemu.vbs") < 1 then
                terminate = false
            end if
        end if
        if terminate then
            process.Terminate
        end if
    next
next


Akkadius 01-01-2013 12:20 AM

Quote:

Originally Posted by blindaviator (Post 215830)
Don't know if this program is known here but I have this setup on my system and it works great.

FireDaemon Pro can setup any program (including command line starts) as a system service for automatic restarts. I have this setup on my server machine to restart any of the 5 services required for the server to run (so far my login server has crashed once and it restarted it within 1 minute and was back online). Program cost is $50 US but IMHO that is cheap for automatic restarts and no minimized command windows to accidentally close. You can download a 30 day trial of it and see if it is to your liking.

Also you can download their program FireDaemon Fusion which gives you a web based interface for access to running services. I give access to this for a trusted friend to restart the server remotely when updating the database. Best parts about this program is it is FREE and it does not require FireDaemon Pro to run.

Don't know if external links are allowed here but the programs are easy enough to find in a google search.

Thanks for the informational post, Rogean was actually looking for something like this before he found one.


All times are GMT -4. The time now is 03:54 PM.

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