Signal handlers added

parent d79eff8b
......@@ -4,6 +4,7 @@ import colorlog
import getopt
import logging
import sys
import signal
from colorlog import info, warning as warn, error
from importlib import import_module
......@@ -301,6 +302,16 @@ def main():
error("Jetconf daemon already running (pidfile exists). Exiting.")
sys.exit(1)
# Set signal handlers
def sig_exit_handler(signum, frame):
os.close(fl)
os.unlink(CONFIG["GLOBAL"]["PIDFILE"])
info("Exiting.")
sys.exit(0)
signal.signal(signal.SIGTERM, sig_exit_handler)
signal.signal(signal.SIGINT, sig_exit_handler)
# Load data model
datamodel = DataHelpers.load_data_model("data/", "data/yang-library-data.json")
......
GLOBAL:
TIMEZONE: "Europe/Prague"
LOGFILE: "/tmp/jetconf.log"
LOGFILE: "-"
PIDFILE: "/tmp/jetconf.pid"
HTTP_SERVER:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment