Skip to content
Advertisement

python program won’t handle systemd KillSignal at reboot

I have a set of LEDs that I start and turn into a specific colour when the machine starts up and during other events. At power-off/reboot I want the LEDs to reset to the default colour.

To achieve this I start a systemd service that starts up the LED code and have a handle for the signal in the python code. Unfortunately I’m not either receiving the signal or the signal is not getting handled.

JavaScript

The system service

JavaScript

What am I doing wrong here? It’s running on Ubuntu. Any help would be appreciated.

Advertisement

Answer

The callback executed by signal expects two arguments. Your implementation does not take any. The right prototype is:

JavaScript

This might have thrown a TypeError upon signal receive and execution. As you forward your logs output to syslog, then the journalctl should have kept a track of this.

Using the above prototype should make your script properly catch and handle the SIGTERM signal (i.e.: the signal registered in the systemd service definition).

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement