Skip to content
Snippets Groups Projects
Commit 61991fe3 authored by ale's avatar ale
Browse files

do not install extra temporary signal handlers

parent efcf8a1f
Branches
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@ import platform
import pwd
import sys
import syslog
import signal
log = logging.getLogger(__name__)
......@@ -108,22 +107,6 @@ def daemonize(opts, main_function, args, support_gevent=False):
os.chown(opts.pidfile, user_pw.pw_uid, user_pw.pw_gid)
os.setuid(user_pw.pw_uid)
if support_gevent:
import gevent
def _sighandler(signum):
log.info('terminated by signal %d' % signum)
pidfile.release()
sys.exit(0)
gevent.signal(signal.SIGTERM, _sighandler, 15)
gevent.signal(signal.SIGINT, _sighandler, 3)
else:
def _sighandler(signum, frame):
log.info('terminated by signal %d' % signum)
pidfile.release()
sys.exit(0)
signal.signal(signal.SIGTERM, _sighandler)
signal.signal(signal.SIGINT, _sighandler)
if not opts.foreground:
null_fd = open(os.devnull, 'r+')
for stream in (sys.stdin, sys.stdout, sys.stderr):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment