0 Members and 1 Guest are viewing this topic.
#!/usr/bin/pythonimport osimport timeimport socketimport structimport sys#CONFIGip = "outcry.u13.net"port = 99999interval = 5run_exec = "nohup ./soldatserver > /dev/null &"#ENDdef check_alive(ip,port): try: sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.connect((ip,int(port))) tv = struct.pack('ii', int(5), int((5-int(5))*1e6)) sock.setsockopt(socket.SOL_SOCKET,socket.SO_RCVTIMEO,tv) ping_p = "i" + "" sock.send(ping_p,0x100); recv = sock.recvfrom(6,0) buff = recv[0] return len(buff) except: return 0print "Keeping "+ip+":"+str(port)+" alive.\nOut:",while 1: if check_alive(ip,int(port)) > 0: print "0" else: print "1_" os.system(run_exec) print "R" time.sleep(interval)
perl ./whateveryounamedit.pl
Also, I suggest you use the script to actually start the server; read: run the script only and it'll take care of running the server.1. Download and edit the config variables2. chmod +x sc.py2. nohup ./sc.py > /dev/null &
1. Download and edit the config variables2. chmod +x sc.py2. nohup ./sc.py > /dev/null &
Is this a script to restart the server automaticaly if it crash??what i have to do?!Quote from: mar77a on November 29, 2007, 07:18:57 am1. Download and edit the config variables2. chmod +x sc.py2. nohup ./sc.py > /dev/null &could i also start it with ./sc.py -d ??