if conf.weatherServerPid is not False: print('Killing old server with pid %d' % conf.weatherServerPid) os.kill(conf.weatherServerPid, signal.SIGTERM) time.sleep(2) conf.serverLoad() server = SocketServer.UDPServer(("localhost", conf.server_port), ClientHandler) # Save pid conf.weatherServerPid = os.getpid() conf.serverSave() # Weather classes gfs = GFS(conf) metar = Metar(conf) wafs = WAFS(conf) # Init worker thread worker = Worker([gfs, metar, wafs], conf.parserate) worker.start() print('Server started.') # Server loop try: server.serve_forever() except KeyboardInterrupt: pass # Close gfs worker and save config worker.shutdown()
def __init__(self, conf): self.conf = conf self.lastgrib = self.conf.lastgrib self.wafs = WAFS(conf) self.metar = Metar(conf) threading.Thread.__init__(self)