ID:140957
 
Code:
world/New()
world.log=file("Monitorlog.txt");
Check_Server()
var/failattempts
proc
Check_Server()
var/SERVER = world.Export("byond://127.0.0.1:1709?ping")
if(!SERVER)
world.log<<"<[time2text(world.timeofday)]> Server failed to respond"
failattempts++;
if(failattempts>2)
world.log<<"<[time2text(world.timeofday)]> Reboot Attempted"
world.log<<"----------------------"
startup("dmu/dmu.dmb",1709,"-trusted")
failattempts=0;
spawn(10)
Check_Server()


Problem description:

This code works perfectly fine on Windows.
However, neither logging output or running of a server works on a Linux machine.

Any ideas?
I'm guessing that the user that BYOND is running on under Linux doesn't have write access to the dmb's directory, and that it doesn't have permission to launch dreamdaemon.

As for your snippet, notice how you can remove a global variable by moving it inside the proc and looping instead of recursively calling the proc over and over:

proc
Check_Server()
var
server = world.Export("byond://127.0.0.1:1709?ping")
fail_ct = 0

while(!server)
world.log << "<[time2text(world.timeofday)]> Server failed to respond"
++fail_ct

if(fail_ct > 2)
world.log << "<[time2text(world.timeofday)]> Reboot Attempted"
world.log << "----------------------"
startup("dmu/dmu.dmb",1709,"-trusted")
break

sleep(10)
In response to Kuraudo
Kuraudo wrote:
I'm guessing that the user that BYOND is running on under Linux doesn't have write access to the dmb's directory, and that it doesn't have permission to launch dreamdaemon.

As for your snippet, notice how you can remove a global variable by moving it inside the proc and looping instead of recursively calling the proc over and over:

proc
> Check_Server()
> var
> server = world.Export("byond://127.0.0.1:1709?ping")
> fail_ct = 0
>
> while(!server)
> world.log << "<[time2text(world.timeofday)]> Server failed to respond"
> ++fail_ct
>
> if(fail_ct > 2)
> world.log << "<[time2text(world.timeofday)]> Reboot Attempted"
> world.log << "----------------------"
> startup("dmu/dmu.dmb",1709,"-trusted")
> break
>
> sleep(10)


Why break the loop after trying to reboot the server? That would mean it only tries to reboot it once?
ALso, where you moved world.Export it would not repeatedly check the status of the server.

Also the user has full access to everything in it's own directory (/home/****, where everything resides which I use) and is allowed to launch everything inside.