From f6af404831d166412f2aa507636ed2825e0e4c0d Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 21 Dec 2009 23:03:12 +0100 Subject: webserver for win --- module/web/ServerThread.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 2ac39c2c8..0d6044562 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -17,16 +17,27 @@ class WebServer(threading.Thread): def run(self): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] + command = ['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,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) - #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: + + if os.name == 'posix': + self.p = Popen(command, 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) + else: + self.p = Popen(command, stderr=PIPE, stdin=PIPE, stdout=PIPE) + while self.running: + sleep(1) def quit(self): - os.kill(self.pid, SIGINT) + if os.name == 'posix': + os.kill(self.pid, SIGINT) + else: + self.p.kill() + self.running = False -- cgit v1.2.3