def main(**kwargs): try: gate = Gateway(**kwargs) gate.run() except KeyboardInterrupt: logging.error("%s: process stopped by user" % (time.strftime("%d%b%Y,%H:%M"))) sys.exit()
def run(self, **kwargs): import sys from modem import Gateway try: gate = Gateway(**kwargs) gate.run() except SystemExit: logging.error("%s: Gateway SIGTERM, exiting" % time.strftime("%d%b%Y,%H:%M")) sys.exit(0)
def run(): import gevent.monkey gevent.monkey.patch_time() import atexit import gevent import signal def sigstop(): sys.exit() gevent.signal(signal.SIGTERM,sigstop) def delpid(): os.remove('test.pid') atexit.register(delpid) from modem import Gateway gate = Gateway() gate.run()