0

I'm running a streaming radio on my Raspberry Pi 3 using MPD (Music Player Daemon). We are only 2 to use this radio, and most of the time, neither of us are connected to listen to the radio, which means that the service is running for nothing. I checked that MPD is idling at 5% CPU and goes up to close to 40% when anyone connects, but in a more general way, I was wondering if there was some interruption, system notification or something like that which could be used to trigger a command, say, when someone connects on a specific port, or disconnects from it.

The goal would be to only run a service when needed.

I am using nginx as server, if that's of any help.

Only thing I could gather is a constant polling like what is mentioned here : https://www.tecmint.com/find-all-clients-connected-to-http-or-https-ports/ But, of course, I would need to be "instantly" reactive and not wait in between two pollings.

Shinkel
  • 11
  • 1
  • Would it be okay to execute a command when a user is connected to the pi, with a simple login. or does it HAVE to be a login from the web? – Kevin C Nov 17 '22 at 07:01
  • From the web only :) Like when anyone connects to the radio site (which runs on a specific port). I'd catch that and, for example, run the daemon. – Shinkel Nov 17 '22 at 07:05
  • https://stackoverflow.com/questions/22891148/how-to-run-a-shell-script-on-every-request – Kevin C Nov 17 '22 at 07:23
  • Oh.... Simple as that. Thank you very much, I'll give it a try! – Shinkel Nov 17 '22 at 07:35

0 Answers0