Moode Forum
gpio-shutdown overlay and Moode SIGTERM handling - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: gpio-shutdown overlay and Moode SIGTERM handling (/showthread.php?tid=3188)



gpio-shutdown overlay and Moode SIGTERM handling - chano22000 - 11-25-2020

Hi,

I just installed the latest moode version on an Audiophonics HiFi streamer (fantastic quality and value for the money - https://www.audiophonics.fr/en/network-audio-players-raspdac/audiophonics-raspdac-lte-i-sabre-es9038q2m-streamer-raspberry-pi-3-b-dac-32-bit-p-13100.html).

The device embeds a separate power supply and management board (https://www.audiophonics.fr/en/raspberry-pi-and-other-sbc-accessories/audiophonics-pi-spc-ii-power-management-power-supply-for-raspberry-pi-p-11504.html). Pressing the front panel hardware button shutdowns the system handeld by a gpio-shutdown overlay.

The time needed to shutdown the sytem this way is significantly shorter than when Moode is shutdown through its interface.

Does-it mean than the graceful shutdown is not the same in both cases ? When shutdown is requested through the UI Moode issues a  "mpc stop" and "systemctl stop nginx".

I understand (I am not a Linux expert) that shutdown (as well as reboot, poweroff ?) sends a sigterm signal to Moode (and other processes)

Q1 : does Moode catch the signal to do the housekeeping ?
Q2 : if not, what are the consequences of a hardware shutdown.

Thank you.

Regards.

Philippe


RE: gpio-shutdown overlay and Moode SIGTERM handling - Tim Curtis - 11-25-2020

Shutdown from moOde WebUI takes ~15 seconds and includes the following:

- Up to 3 secs for moOde's job processing daemon to wake up and process the "poweroff" job sent from the WebUI
- Poweroff job executes the script /var/local/www/commandw/restart.sh poweroiff
- The poweroff section in restart.sh stops playback, stops the nginx web server then executes linux poweroff command
- The poweroff command shuts Linux down and powers off the Raspberry Pi (power LED flashes 10 times)

moOde does not catch or process any SIGTERM signals.
I have no idea what the audiophonics power board does.


RE: gpio-shutdown overlay and Moode SIGTERM handling - chano22000 - 11-25-2020

Hi Tim,

Thank you for your answer. Among other things, the hardware power button attached to the Audiophonic boards is wired to one GPIO pin. Pressing the button shutdowns the system (dtoverlay=gpio-shutdown,gpio_pin=17,active_low=0,gpio_pull=down added in config.txt).

I understand fom your answer that shutting down the sytem this way does not make Moode stop mpc playback (mpc stop), nor nginx (systemctl stop nginx).

Q1 : do you know wether mpc or nginx catch and process any shutdown related signal and do their own housekeeping ?
Q2 : if not, do you anticipate any issue raised from this "not fully" graceful shutdown ?

Best regards.

Philippe


RE: gpio-shutdown overlay and Moode SIGTERM handling - vinnn - 11-25-2020

@chano22000
A system shutdown on Linux stops everything gracefully, otherwise it wouldn't be a shutdown. Just executing "poweroff" is sufficient, all services are stopped, processes are sent a sigterm signal and filesystems are synced before the system is powered off.
Alternatively executing "poweroff -f" performs an immediate ungraceful system halt.


RE: gpio-shutdown overlay and Moode SIGTERM handling - chano22000 - 11-25-2020

@vinnn : Thank you.

A far as I understand and if the Raspbian implementation has not changed, the dtoverlay=gpio-shutdown generates a KEY_POWER event which is processed according to /etc/systemd/logind.conf which is "poweroff" by default

I am fully reassured !