]> git.gag.com Git - fw/quantimotor/commitdiff
arrange for systemd to trigger graceful shutdown without CherryPy involved
authorBdale Garbee <bdale@gag.com>
Sat, 5 Apr 2025 07:02:51 +0000 (01:02 -0600)
committerBdale Garbee <bdale@gag.com>
Sat, 5 Apr 2025 07:02:51 +0000 (01:02 -0600)
application.py
debian/quantimotor.service

index 6eb057dc183ad0b609f7ec8de83adcf5190ad285..862e74e8da92cb2d4e6511f7acef0d1ebc97d634 100755 (executable)
@@ -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)
 
index 3940c2369537d15f86959d406ca6dc402c5e7087..395074364e7c711c395d34d940734b785804d439 100644 (file)
@@ -5,6 +5,7 @@ After=network.target
 [Service]
 Type=simple
 ExecStart=/usr/share/quantimotor/startup
+KillSignal=SIGINT
 
 [Install]
 WantedBy=multi-user.target