G_exit = True os._exit(0) signal(SIGINT, sig_exit) signal(SIGTERM, sig_exit) # eventlet 与 multiprocessing冲突,所以要将eventlet # 放在最后加载 from pm_srvd import PMService srvd = PMService() srvd._port = 6000 srvd.listen() """ t = Thread(target= srvd.listen) t.setDaemon(True) t.start() while True:
import logging.config import ipswrap try: from Queue import Queue except: from queue import Queue from system_info import get_ip from pm_srvd import PMService import setproctitle from signal import signal, SIGINT, SIG_IGN #设置程序名 proc_title = "tools-srvd" setproctitle.setproctitle(proc_title) sys.path.append("%s/%s" % (sys.path[0],'modules')) """初始化配置""" logging.config.fileConfig('./conf/logging.conf') logger = logging.getLogger('main') config.read('./conf/worker.conf') G_exit = False SERVER = config.CONFIG['server'] #配置文件信息 #信号处理 def sig_exit(a,b): G_exit=True os._exit(0) signal(SIGINT,sig_exit) srvd = PMService() srvd.listen()
from stat_daemon import cron p = mp.Process(target=cron, args=(mpexit,)) p.daemon = True p.start() #信号处理 def sig_exit(a,b): mpexit.set() G_exit=True os._exit(0) signal(SIGINT,sig_exit) signal(SIGTERM,sig_exit) #eventlet 与 multiprocessing冲突,所以要将eventlet #放在最后加载 from pm_srvd import PMService srvd = PMService() srvd._port = sconf.SYS['port'] srvd.listen() """ t = Thread(target= srvd.listen) t.setDaemon(True) t.start() while True: if G_exit: mpexit.set() p.join() os._exit(0) time.sleep(1) """