From 6b8a6619533c7f47a63e041efb516ad91b10b4da Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Mon, 20 Apr 2020 08:58:20 -0500 Subject: http api: T2292: handle SIGTERM from systemd restart; raise SIGINT --- src/services/vyos-http-api-server | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/services') diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index b5ad8b159..a3624052e 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -22,6 +22,7 @@ import grp import json import traceback import threading +import signal import vyos.config @@ -350,6 +351,8 @@ def show_op(): return success(res) +def shutdown(): + raise KeyboardInterrupt if __name__ == '__main__': # systemd's user and group options don't work, do it by hand here, @@ -372,4 +375,9 @@ if __name__ == '__main__': app.config['vyos_keys'] = server_config['api_keys'] app.config['vyos_debug'] = server_config['debug'] + def sig_handler(signum, frame): + shutdown() + + signal.signal(signal.SIGTERM, sig_handler) + bottle.run(app, host=server_config["listen_address"], port=server_config["port"], debug=True) -- cgit v1.2.3