diff options
| -rw-r--r-- | module/web/ServerThread.py | 27 | 
1 files changed, 19 insertions, 8 deletions
| 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 | 
