[IMP] Add the signal handlers

bzr revid: stephane@tinyerp.com-20081223172718-umgii173klrcmfad
This commit is contained in:
Stephane Wirtel 2008-12-23 18:27:18 +01:00
parent f4a6b51fb4
commit fcad7df0ed
1 changed files with 3 additions and 10 deletions

View File

@ -55,14 +55,6 @@ __version__ = release.version
import netsvc
logger = netsvc.Logger()
def atexit_callback():
logger.notifyChannel('shutdown', netsvc.LOG_INFO, "Shutdown Server!")
#logger.notifyChannel('pan! pan!', netsvc.LOG_INFO, "Killed Server ;-)")
import atexit
atexit.register(atexit_callback)
#-----------------------------------------------------------------------
# import the tools module so that the commandline parameters are parsed
#-----------------------------------------------------------------------
@ -201,6 +193,7 @@ def handler(signum, frame):
netsvc.Agent.quit()
if config['pidfile']:
os.unlink(config['pidfile'])
logger.notifyChannel('shutdown', netsvc.LOG_INFO, "Shutdown Server!")
sys.exit(0)
from tools import config
@ -210,8 +203,8 @@ if config['pidfile']:
fd.write(pidtext)
fd.close()
signal.signal(signal.SIGINT, handler)
signal.signal(signal.SIGTERM, handler)
for sign in ('SIGINT', 'SIGTERM', 'SIGUSR1', 'SIGQUIT'):
signal.signal(getattr(signal, sign), handler)
logger.notifyChannel("web-services", netsvc.LOG_INFO, 'the server is running, waiting for connections...')
if tools.config['netrpc']: