From 261d9394dba1b7f83f309136119896aee03872ba Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sat, 16 Jun 2018 22:30:17 -0400 Subject: [PATCH] Support proper sigterm exiting --- pvcd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pvcd.py b/pvcd.py index 628bc846..95a22922 100755 --- a/pvcd.py +++ b/pvcd.py @@ -24,6 +24,7 @@ import kazoo.client import libvirt import sys import os +import signal import socket import psutil import subprocess @@ -120,6 +121,9 @@ def cleanup(): zk.close() update_timer.shutdown() +# Handle SIGTERM gracefully +signal.signal(signal.SIGTERM, cleanup) + # Gather useful data about our host for staticdata # Static data format: 'cpu_count', 'arch', 'os', 'kernel' staticdata = []