From 63d4273065f475719e63e5785abdbf11be43dae3 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 21 Dec 2009 19:19:28 +0100 Subject: reverted files, pyload.db fix --- module/web/ServerThread.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index cebf0ce2f..2ac39c2c8 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,9 +1,11 @@ #!/usr/bin/env python +from __future__ import with_statement import threading from os.path import join from subprocess import Popen, PIPE, STDOUT from time import sleep from signal import SIGINT +import os class WebServer(threading.Thread): def __init__(self, pycore): @@ -16,13 +18,15 @@ class WebServer(threading.Thread): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) ) - 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=False) + 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) #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port))) #@TODO: better would be real python code + sleep(1) + with open("webserver.pid", "r") as f: + self.pid = int(f.read().strip()) while self.running: sleep(1) def quit(self): - self.p.terminate() + os.kill(self.pid, SIGINT) self.running = False - -- cgit v1.2.3