send shutdown on sigterm
This commit is contained in:
@@ -37,6 +37,9 @@ def log(msg):
|
||||
else:
|
||||
print msg
|
||||
|
||||
def handler(signum, frame):
|
||||
if signum == signal.SIGTERM:
|
||||
cleanup()
|
||||
|
||||
class NullDevice:
|
||||
def write(self, s):
|
||||
@@ -329,6 +332,8 @@ def process():
|
||||
|
||||
def cleanup():
|
||||
global running
|
||||
if not running:
|
||||
return
|
||||
if verbose: log('cleanup')
|
||||
running = False
|
||||
for conn in conns:
|
||||
@@ -538,6 +543,7 @@ if fdaemon:
|
||||
daemonized = True
|
||||
syslog.syslog(syslog.LOG_ERR, 'starting heartbeat to %s' % ','.join(hb_hosts))
|
||||
|
||||
signal.signal(signal.SIGTERM, handler)
|
||||
running = True
|
||||
try:
|
||||
process()
|
||||
|
||||
Reference in New Issue
Block a user