Note that there are some explanatory texts on larger screens.

plurals
  1. POPython watchdog application
    text
    copied!<p>Erm... i promise i searched thoroughly the web for this and couldn't find a satisfatory answer so >.&lt;</p> <p>I'm trying to make a 'controller' for my python app, i mean, it should be executed and then spawn the server, wait to pickup exit signals and if necessary, restart the script.</p> <p>This code is pretty messy but that's what i've come with so far... It always returns with unrecognized exitSignal 1 and won't even spawn the server process! Can someone give me a light please?</p> <pre><code>#Server controller version 0.1 import os import time from datetime import datetime Log = file("C:/Users/Admin/Desktop/Python/Server/WIP.log", 'w') def runServer(): exitSignal = os.spawnv(os.P_WAIT, 'C:/Python2.7/python.exe', ['python.exe', 'C:/Users/Admin/Desktop/Python/Server/WIP.py']) print str(datetime.today())+" - Server started" Log.write("\n"+str(datetime.today())+" - Server started") if exitSignal == "0": print str(datetime.today())+" - Server exited succesfully." Log.write("\n"+str(datetime.today())+" - Server exited succesfully.") elif exitSignal == "10": print str(datetime.today())+" - Rebooting server immediately." Log.write("\n"+str(datetime.today())+" - Rebooting server immediately.") runServer() elif exitSignal == "11": print str(datetime.today())+" - Rebooting server in 5 minutes." Log.write("\n"+str(datetime.today())+" - Rebooting server in 5 minutes.") time.sleep(300) runServer() print str(datetime.today())+" - Server rebooted." Log.write("\n"+str(datetime.today())+" - Server rebooted.") else: print str(datetime.today())+" - Unrecognized exitSignal code: %s" % str(exitSignal) Log.write("\n"+str(datetime.today())+" - Unrecognized exitSignal code: %s" % str(exitSignal)) if __name__ == "__main__": print str(datetime.today())+" - Controller started." Log.write("\n"+str(datetime.today())+" - Controller started") runServer() </code></pre> <p>Sorry for the messy code! (=^,^=)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload