Moode Forum
Poweroff hardware button and Moode graceful shutdown - 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: Poweroff hardware button and Moode graceful shutdown (/showthread.php?tid=3155)



Poweroff hardware button and Moode graceful shutdown - chano22000 - 11-13-2020

Hi,

I have ordered an audio streamer from Audiophonics which is planned to run Moode. The device embeds an ATX-like power supply & 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). Some scripts are required for the board to get the state of the system (booting, application running, rebooting, shutting down...) in order to handle a front panel system status LED and properly cut the power off after the system is halted.

My concern is about monitoring the hardware power button when the system is running (button pressed = shutdown request) and handling a clean shutdown of moode.

A basic solution is to lauch a script during boot that periodically polls the relevant GPIO input pin to checks wether the power button is depressed. This is what Audiphonics suggests with a period of 0.25s. The Moode "GPIO button handler" does the same and could be used for the same purpose.

An more "modern" approach is suggested which uses overlay :
dtoverlay=gpio-shutdown,gpio_pin=17,active_low=0,gpio_pull=down in boot/config.txt (customized for Audiophonics hardware)

Q1 : Should this alternative be preferred as it might be implemented more efficiently deeper into the system ?

Q2 : Does this solution gracefully shutdown Moode ? (when shutdown is handled through the Moode interface, mpd and nginx are stopped before poweroff)

Q3 : Is there a way using the overlay approach to have a script executed (which would cleanly shutdown the system instead of only issuing a shutdown) when a transition occurs on the GPIO input pin ?

Q4 : Apart from stopping mpc an nginx, are there other (background) processes to take care off (such as music library indexing) when shutdown is requested outside the Moode user interface ?

(I am a newbie with overall IT culture but poor Pi and Linux knowledge)

Thank you for the tremendous work (I will make a donation as soon as my future system is running !)

Kind regards.

Philippe


RE: Poweroff hardware button and Moode graceful shutdown - bitlab - 11-13-2020

I have taken almost the same approach with a soft power down circuit with a overlay for requesting (input) an power down and and overlay for providing the pi status (output). Described in this article.

A1: Yes
A2: Yes it gracefully shutdown the entire OS and applications running on the Pi.
A3: No need for it. See A2.
A4: No need for it. See A2.


RE: Poweroff hardware button and Moode graceful shutdown - chano22000 - 11-14-2020

Hi bitlab,

Thank you very much for your prompt and detailed answer. I will go the "gpio-shutdown" way for efficiently monitoring the power button but will keep the scripts instead of using a gpio-poweroff overlay. As far as I understand, the Audiophonics power board uses two GPIO outputs in order to make the difference between reboot or shutdown when requested by moode and handle the power button LED accordingly (slow/fast  blinking).

Regards.