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