From: Bdale Garbee Date: Sat, 5 Apr 2025 07:02:51 +0000 (-0600) Subject: arrange for systemd to trigger graceful shutdown without CherryPy involved X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=aefa7246154406bd8647b7167b2dff5c2bd7ded6;p=fw%2Fquantimotor arrange for systemd to trigger graceful shutdown without CherryPy involved --- diff --git a/application.py b/application.py index 6eb057d..862e74e 100755 --- a/application.py +++ b/application.py @@ -30,6 +30,22 @@ def set_line_values(chip_path, line_values): ) request.set_values(line_values) +def handler(signum, frame): + set_line_values( + "/dev/gpiochip0", + { 4: Value.INACTIVE, # indicate 'not ready' to LPC + 16: Value.INACTIVE, # pyro off + 17: Value.INACTIVE, # alarm b off + 20: Value.INACTIVE, # turn continuity LED off + 21: Value.INACTIVE, # turn armed LED off + 27: Value.INACTIVE # alarm a off + } + ) + sys.exit(0) + +# having systemd use SIGINT to avoid CherryPy consuming the kill signal +signal.signal(signal.SIGINT, handler) + class Root(object): @cherrypy.expose @@ -85,6 +101,6 @@ if __name__ == '__main__': 'server.socket_port': 8080, }, } - + cherrypy.quickstart(Root(), '/', config) diff --git a/debian/quantimotor.service b/debian/quantimotor.service index 3940c23..3950743 100644 --- a/debian/quantimotor.service +++ b/debian/quantimotor.service @@ -5,6 +5,7 @@ After=network.target [Service] Type=simple ExecStart=/usr/share/quantimotor/startup +KillSignal=SIGINT [Install] WantedBy=multi-user.target