Commit 0050bbb2 authored by ale's avatar ale

do not write pidfile with --foreground

parent 6ae702bb
......@@ -87,17 +87,19 @@ def daemonize(opts, main_function, *args):
setup_logging(opts.foreground, opts.debug)
pidfile = PIDFile(opts.pidfile)
try:
pidfile.acquire()
except Exception, e:
log.fatal('could not write pidfile: %s' % str(e))
sys.exit(1)
if not opts.foreground:
pidfile = PIDFile(opts.pidfile)
try:
pidfile.acquire()
except Exception, e:
log.fatal('could not write pidfile: %s' % str(e))
sys.exit(1)
def _sighandler(signum, frame):
log.info('terminated by signal %d' % signum)
try:
pidfile.release()
if not opts.foreground:
pidfile.release()
except Exception, e:
log.error('could not remove pidfile: %s' % e)
sys.exit(0)
......@@ -113,7 +115,8 @@ def daemonize(opts, main_function, *args):
try:
main_function(*args)
finally:
pidfile.release()
if not opts.foreground:
pidfile.release()
def add_options(parser):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment