diff options
author | mkaay <mkaay@mkaay.de> | 2009-12-20 20:54:30 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2009-12-20 20:54:30 +0100 |
commit | c003c8a342cbe9609f8e6b21669a8b4a90a213bf (patch) | |
tree | 1cf1fc6001f97d5299c11fad4b7581e00c158911 /module | |
parent | fixed file_list, clean exit? (diff) | |
download | pyload-c003c8a342cbe9609f8e6b21669a8b4a90a213bf.tar.xz |
fixed file_list again, webserver terminates correctly when killing pyload over xmlrpc
Diffstat (limited to 'module')
-rw-r--r-- | module/web/ServerThread.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 6113ac297..2279296d8 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,21 +1,27 @@ #!/usr/bin/env python import threading from os.path import join -import subprocess +from subprocess import Popen, PIPE, STDOUT +from time import sleep +from signal import SIGINT class WebServer(threading.Thread): def __init__(self, pycore): threading.Thread.__init__(self) self.pycore = pycore + self.running = True self.setDaemon(True) def run(self): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) ) - try: - subprocess.call(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True) - except Exception, e: - print e + self.p = Popen(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True, stderr=PIPE, stdin=PIPE, stdout=PIPE, shell=True) #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port))) #@TODO: better would be real python code + while self.running: + sleep(1) + + def quit(self): + self.p.terminate() + self.running = False |