//Made by Masterdan
world/New()
..()
spawn()Checkout()
world<<"Welcome to Masterdan's Server Control Panel V0.10"
var
oServers=new/list()
counter=1
OS="Windows" //Linux
busy=0
obj/Server
var
Port
Location
mob
verb/Start_Server()
var/S=input(usr,"Define a Server path ie Naruto.dmb","Server") as text
var/P=input(usr,"Set a Port","Port") as num
var/obj/Server/G=new/obj/Server()
G.Location=S
G.name=S
G.Port=P
oServers+=G
counter++
busy=1
startup(file("[S]"),P,"-trusted")
sleep(200)
busy=0
verb/Check_Servers()
world<<"Checking Servers.."
for(var/obj/Server/X in oServers)
world<<"[X.Location]:[X.Port]"
verb/Stop_Server()
var/obj/Server/D=input(usr,"Stop Keep-Alive for which server?","Stop") in oServers
del(D)
proc/Checkout()
while(1)
sleep(100)
for(var/obj/Server/X in oServers)
if(busy)
sleep(10)
continue
world<<"Checking [X]"
var/port=X.Port
var/file_loc=X.Location
var/ping=world.Export("byond://localhost:[port]?ping")
sleep(50)
if(!ping)
world<<"[X.name] no ping!"
sleep(50)
ping=world.Export("byond://localhost:[port]?ping")
if(!ping)
shutdown("byond://localhost:[port]",0)
world<<"[X.name] still no ping! Restarting"
startup(file("[file_loc]"),port,"-trusted")
world<<"Started up [port]"
What this does is allows server owners to launch a game through this environment and it will keep it running if it crashes. And it supports multiple servers etc etc.
Problem is, the ping export sucks ass. There being no timeout means that if the server actually has crashed or locked up permanently the tool will be rendered useless. Which sucks bigtime. Im currently thinking of some way of having spawned code running concurrently and a variable and my own timeout code. Not only do i think its stupid for export to lack a timeout argument but now im taking suggestions on how to tactfully do this. I have in the past but i am not satisfied with the messy way i did it (and i cant remember it clearly) and i wanted to know what the best way to approach this was.