diff options
author | John Estabrook <jestabro@vyos.io> | 2020-04-20 08:58:20 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2020-04-20 09:00:22 -0500 |
commit | 6b8a6619533c7f47a63e041efb516ad91b10b4da (patch) | |
tree | e76412786c8420729ecc7517d6dd256964758465 | |
parent | cfc474b3e45762e0c15f9cfca76a3c1b66ff233e (diff) | |
download | vyos-1x-6b8a6619533c7f47a63e041efb516ad91b10b4da.tar.gz vyos-1x-6b8a6619533c7f47a63e041efb516ad91b10b4da.zip |
http api: T2292: handle SIGTERM from systemd restart; raise SIGINT
-rwxr-xr-x | src/services/vyos-http-api-server | 8 |
1 files changed, 8 insertions, 0 deletions
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) |