Revert "[#3] Add some correction to handle this properly"
This reverts commit ac2b3c464c
.
This commit is contained in:
parent
9eb1855add
commit
f27cdb024c
11
pvcd.py
11
pvcd.py
|
@ -142,7 +142,7 @@ def zk_listener(state):
|
||||||
zk_conn.add_listener(zk_listener)
|
zk_conn.add_listener(zk_listener)
|
||||||
|
|
||||||
# Cleanup function
|
# Cleanup function
|
||||||
def cleanup():
|
def cleanup(signum, frame):
|
||||||
ansiiprint.echo('Terminating daemon', '', 'e')
|
ansiiprint.echo('Terminating daemon', '', 'e')
|
||||||
# Set stop state in Zookeeper
|
# Set stop state in Zookeeper
|
||||||
zk_conn.set('/nodes/{}/daemonstate'.format(myhostname), 'stop'.encode('ascii'))
|
zk_conn.set('/nodes/{}/daemonstate'.format(myhostname), 'stop'.encode('ascii'))
|
||||||
|
@ -150,6 +150,8 @@ def cleanup():
|
||||||
zk_conn.close()
|
zk_conn.close()
|
||||||
# Stop keepalive thread
|
# Stop keepalive thread
|
||||||
stopKeepaliveTimer(update_timer)
|
stopKeepaliveTimer(update_timer)
|
||||||
|
# Exit
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# Flush function
|
# Flush function
|
||||||
def flush():
|
def flush():
|
||||||
|
@ -157,18 +159,15 @@ def flush():
|
||||||
this_node.flush()
|
this_node.flush()
|
||||||
|
|
||||||
# Shutdown function
|
# Shutdown function
|
||||||
def dshutdown(signum, frame):
|
def dshutdown():
|
||||||
ansiiprint.echo('Flushing this node', '', 'e')
|
ansiiprint.echo('Flushing this node', '', 'e')
|
||||||
flush()
|
flush()
|
||||||
ansiiprint.echo('NOTE: This node must be unflushed by the administrator after daemon startup', '', 'i')
|
ansiiprint.echo('NOTE: This node must be unflushed by the administrator after daemon startup', '', 'i')
|
||||||
cleanup()
|
cleanup()
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Reload shutdown function
|
# Reload shutdown function
|
||||||
def dreload(signum, frame):
|
def dreload():
|
||||||
cleanup()
|
cleanup()
|
||||||
python = sys.executable
|
|
||||||
os.execl(python, python, *sys.argv)
|
|
||||||
|
|
||||||
# Handle signals gracefully
|
# Handle signals gracefully
|
||||||
signal.signal(signal.SIGTERM, dshutdown)
|
signal.signal(signal.SIGTERM, dshutdown)
|
||||||
|
|
Loading…
Reference in New Issue