Implement pid file for --daemon
This commit is contained in:
2
mumo.ini
2
mumo.ini
@@ -36,7 +36,7 @@ cfg_dir = modules-enabled/
|
|||||||
timeout = 2
|
timeout = 2
|
||||||
|
|
||||||
[system]
|
[system]
|
||||||
pidfile = muauth.pid
|
pidfile = mumo.pid
|
||||||
|
|
||||||
|
|
||||||
; Logging configuration
|
; Logging configuration
|
||||||
|
|||||||
6
mumo.py
6
mumo.py
@@ -63,6 +63,7 @@ default.update({'ice':(('host', str, '127.0.0.1'),
|
|||||||
|
|
||||||
'iceraw':None,
|
'iceraw':None,
|
||||||
'murmur':(('servers', commaSeperatedIntegers, []),),
|
'murmur':(('servers', commaSeperatedIntegers, []),),
|
||||||
|
'system':(('pidfile', str, 'mumo.pid'),),
|
||||||
'log':(('level', int, logging.DEBUG),
|
'log':(('level', int, logging.DEBUG),
|
||||||
('file', str, 'mumo.log'))})
|
('file', str, 'mumo.log'))})
|
||||||
|
|
||||||
@@ -463,6 +464,7 @@ if __name__ == '__main__':
|
|||||||
if option.force_app:
|
if option.force_app:
|
||||||
raise ImportError # Pretend that we couldn't import the daemon lib
|
raise ImportError # Pretend that we couldn't import the daemon lib
|
||||||
import daemon
|
import daemon
|
||||||
|
import daemon.pidlockfile
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if option.force_daemon:
|
if option.force_daemon:
|
||||||
print >> sys.stderr, 'Fatal error, could not daemonize process due to missing "daemon" library, ' \
|
print >> sys.stderr, 'Fatal error, could not daemonize process due to missing "daemon" library, ' \
|
||||||
@@ -470,8 +472,10 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
ret = do_main_program()
|
ret = do_main_program()
|
||||||
else:
|
else:
|
||||||
|
pidfile = daemon.pidlockfile.TimeoutPIDLockFile(cfg.system.pidfile, 5)
|
||||||
context = daemon.DaemonContext(working_directory=sys.path[0],
|
context = daemon.DaemonContext(working_directory=sys.path[0],
|
||||||
stderr=logfile)
|
stderr=logfile,
|
||||||
|
pidfile=pidfile)
|
||||||
context.__enter__()
|
context.__enter__()
|
||||||
try:
|
try:
|
||||||
ret = do_main_program()
|
ret = do_main_program()
|
||||||
|
|||||||
Reference in New Issue
Block a user