philippe44 / AirConnect

Use AirPlay to stream to UPnP/Sonos & Chromecast devices
Other
3.52k stars 218 forks source link

No Automatic start on Rpi4 with Hoobs (service succeedes but device will not show) #438

Closed cronusfortunam closed 1 year ago

cronusfortunam commented 1 year ago

Dear @philippe44 thanks for AirConnect!

I havechmod +x aircast-linux-arm in a Raspberry Pi 4 runing Hoobs and set systemd so that it runs after booting. When I run ./aircast-linux-arm -z, it work and my Google-Home-Mini shows up in all of my Apple devices and it streams. Whoever, when I reboot the Pi, the Google-Home-Mini does not show up anymore but journalctl shows that the Service has succeeded.

Here is the output after boot:

journalctl -u airplay.service

> -- Boot 617ded64b9734316bfa19640b268ceab --
Nov 29 01:31:21 hoobs systemd[1]: Started AirUPnP bridge.
Nov 29 01:31:21 hoobs aircast-linux-arm[772]: [01:31:21.158539] main:884 Starting aircast version: v1.0.12 (Nov 21 2022 @ 22:15:38)
Nov 29 01:31:21 hoobs aircast-linux-arm[772]: [01:31:21.158766] main:891 no config file, using defaults
Nov 29 01:31:21 hoobs systemd[1]: airplay.service: Succeeded. 

This is my airplay.service file

cat /lib/systemd/system/airplay.service I also tried placing it in /etc/systemd/system/

 [Unit]
 Description=AirUPnP bridge
 After=network-online.target
 Wants=network-online.target

 [Service]
 ExecStart=/home/hoobs/aircast-linux-arm -z
 Restart=on-failure
 RestartSec=30

 [Install]
 WantedBy=multi-user.target

So, unfortunately, now every time I reboot the Pi I must run the executable.

How can I set it automaticly? What did I do wrong? Does anyone have a similar issue?

I thank you in advance.

Cronus

philippe44 commented 1 year ago

Did you look at the service example i provided in the README? Your has a wrong combination of background & interactive options

cronusfortunam commented 1 year ago

Did you look at the service example i provided in the README? Your has a wrong combination of background & interactive options

I did, I followed your README. But I am afraid I do not understand. What do you mean I've got a wrong combination of background and interactive options? what should it be in my case?.

thanks for the quick response.

cronusfortunam commented 1 year ago

Should I delete the -z from my airplay.service file?

What are the Interactive options?

Thanks @philippe44

philippe44 commented 1 year ago

It is explained in the README, make sure you read it entirely and use the service example. Your mod wanted to leave airconnect being interactive (ie receiving commands from keyboard) but backgrounded. As the README says, it's not possible

cronusfortunam commented 1 year ago

Thanks @philippe44 I have edited my airplay.service to look like this:

[Unit]
Description=Aircast bridge
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/home/hoobs/aircast-linux-arm
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target

It's diferent than the example you provided but its the only way I can make it to appear in my Apple devicesafter sereral tryouts. I also tryed replacing -z for -Z but this method worked just after the first reboot, after another reboot, the service hanged in: Nov 29 17:39:35 hoobs aircast-linux-arm[830]: [17:39:35.918605] Start:662 Binding to <IP>

The README is very completed, im sure its everything there. But I am new to this wold so many of the terms and new to me as you probably notice. XD

Please let me know if I got it right this time. and if so, this issue can be consider as closed

A big thanks to you !!!

philippe44 commented 1 year ago

As per what's said here https://github.com/philippe44/AirConnect#common-information, you should use -Z in a service, otherwise the app might eat all CPU when it is running as a daemon, which systemd does.

The issue after a reboot is not related. If we are talking about a reboot of your computer, this has to be a totally different issue, like when you reboot the IP address is not given properly or too late or I don't know what and omitting -Z just make the app eating CPU and makes things slow enough so that the IP address is obtained when it starts. Something like that.

cronusfortunam commented 1 year ago

Correct! My CPU was running at +27% without -Z and I did not notice

It Works! It always worked 🙃 but I was not patient enough; it can take up to 6 minutes after boot for the service to add the cast device.

CPU runs now under 7% after adding -Z back to my airplay.service. I just don't understand what my interactive options where and how where they in conflict with the background before?

Nevertheless, I could not be more great full @philippe44.

philippe44 commented 1 year ago

Interactive means that it reads keyboard input and respond to a few commands. A background process cannot do that obviously and trying to access stdin (standard input) from such process has the CPU consumption issue

cronusfortunam commented 1 year ago

Thanks a lot!!!