hzeller / gmrender-resurrect

Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
GNU General Public License v2.0
850 stars 207 forks source link

systemd service #237

Closed parasange closed 3 years ago

parasange commented 3 years ago

I crated a new service file with sudo systemctl edit --force --full gemediarender.service and the following content:

[Unit]
Description=gmrender-resurrect service
After=network.target sound.target

[Service]
Environment="UPNP_DEVICE_NAME=Raspberry"
ExecStartPre=/bin/sh -c "/bin/systemctl set-environment UPNP_UUID=`ip link show | awk '/ether/ {print \"salt:)-\" $2}' | head -1 | md5sum | awk '{print $1}'`"

ExecStart=/usr/local/bin/gmediarender -f "$UPNP_DEVICE_NAME" -u "$UPNP_UUID" \
                                      --gstout-audiosink=alsasink --gstout-audiodevice=sysdefault \
                                      --logfile=/tmp/gmediarenderer.log --gstout-initial-volume-db=-10
Restart=always

[Install]
WantedBy=multi-user.target

I then enabled it sudo systemctl enable gmediarender and reload the daemon sudo systemctl daemon-reload

After a reboot the service seems to be running, ps -fC gmediarender shows the process, but it does not seem to be recognized by pulseaudio-dlna on the other side. Only when i restart the gmediarender service, it is recognized. sudo systemctl status gmediarender.service gives:

● gmediarender.service - gmrender-resurrect service
   Loaded: loaded (/etc/systemd/system/gmediarender.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-07-13 22:02:43 BST; 3min 49s ago
 Main PID: 480 (gmediarender)
    Tasks: 80 (limit: 4322)
   CGroup: /system.slice/gmediarender.service
           └─480 /usr/local/bin/gmediarender -f Rasbpi4 -u ebcfc063ce3e00e3adf2967d6bf97743 --gstout-audiosink=alsasink --gsto

Jul 13 22:02:43 rasbpi4 systemd[1]: Starting gmrender-resurrect service...
Jul 13 22:02:43 rasbpi4 systemd[1]: Started gmrender-resurrect service.
Jul 13 22:02:56 rasbpi4 gmediarender[480]: Ready for rendering

Do you have any idea why it's not loading after boot?

hzeller commented 3 years ago

If you output the logs after the boot, what do you see ?

sudo journalctl -n50 -f -u gmediarender.service
hzeller commented 3 years ago

Maybe also add network-online.target as requirement ?

After=network.target network-online.target
parasange commented 3 years ago

If you output the logs after the boot, what do you see ?

sudo journalctl -n50 -f -u gmediarender.service

I rebootet and service seems to be running fine.

-- Logs begin at Wed 2021-07-14 07:26:55 BST. --
Jul 14 07:26:59 rasbpi4 systemd[1]: Starting gmrender-resurrect service...
Jul 14 07:26:59 rasbpi4 systemd[1]: Started gmrender-resurrect service.
Jul 14 07:27:11 rasbpi4 gmediarender[496]: Ready for rendering.
parasange commented 3 years ago

Maybe also add network-online.target as requirement ?

After=network.target network-online.target

I edited the line After=network.target network-online.target sound.target, restarted the daemon and rebootet. Unfortunately still no progress. Pulsaudio-dlna does not discover the renderer.

Log is again:

-- Logs begin at Wed 2021-07-14 07:35:49 BST. --
Jul 14 07:35:53 rasbpi4 systemd[1]: Starting gmrender-resurrect service...
Jul 14 07:35:53 rasbpi4 systemd[1]: Started gmrender-resurrect service.
Jul 14 07:36:05 rasbpi4 gmediarender[496]: Ready for rendering.
hzeller commented 3 years ago

if you have both interfaces connected (ethernet and wireless) it is probably unclear on which interface the renderer is listening; you can force that with --interface-name.

Can you pass --logfile=stdout to better see details, such as which IP address it binds to in the logfile ?

parasange commented 3 years ago

--interface-nam

if you have both interfaces connected (ethernet and wireless) it is probably unclear on which interface the renderer is listening; you can force that with --interface-name.

Can you pass --logfile=stdout to better see details, such as which IP address it binds to in the logfile ?

Sure, and thanks for your help so far.

ip -br addr shows

lo               UNKNOWN        127.0.0.1/8 ::1/128 
eth0             DOWN           
wlan0            UP             192.168.0.108/24 2a02:8071:2b95:9300:5078:2130:7d0d:ba9e/64 fe80::a187:2610:a756:7bf6/64 

So I edited the systemd service to

ExecStart=/usr/local/bin/gmediarender -f "$UPNP_DEVICE_NAME" -u "$UPNP_UUID" \
                                      --gstout-audiosink=alsasink --gstout-audiodevice=sysdefault \
                                      --logfile=stdout --interface-name=wlan0 --gstout-initial-volume-db=-10

Is that correct?

journalctl -n50 is now:


Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757716 | connmgr] Registering support for 'video/x-prores'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757725 | connmgr] Registering support for 'video/x-pva'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757734 | connmgr] Registering support for 'video/x-pwc1'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757743 | connmgr] Registering support for 'video/x-pwc2'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757752 | connmgr] Registering support for 'video/x-qdrw'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757761 | connmgr] Registering support for 'video/x-qt-part'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757771 | connmgr] Registering support for 'video/x-raw'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757780 | connmgr] Registering support for 'video/x-rle'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757793 | connmgr] Registering support for 'video/x-smc'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757803 | connmgr] Registering support for 'video/x-smoke'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757812 | connmgr] Registering support for 'video/x-sonix'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757821 | connmgr] Registering support for 'video/x-svq'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757829 | connmgr] Registering support for 'video/x-theora'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757924 | connmgr] Registering support for 'video/x-truemotion'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757935 | connmgr] Registering support for 'video/x-tscc'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757944 | connmgr] Registering support for 'video/x-ultimotion'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.757953 | connmgr] Registering support for 'video/x-unaligned-raw'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758038 | connmgr] Registering support for 'video/x-vmnc'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758051 | connmgr] Registering support for 'video/x-vp3'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758059 | connmgr] Registering support for 'video/x-vp5'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758068 | connmgr] Registering support for 'video/x-vp6'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758077 | connmgr] Registering support for 'video/x-vp6-alpha'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758161 | connmgr] Registering support for 'video/x-vp6-flash'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758173 | connmgr] Registering support for 'video/x-vp8'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758182 | connmgr] Registering support for 'video/x-vp9'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758191 | connmgr] Registering support for 'video/x-wmv'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758200 | connmgr] Registering support for 'video/x-xan'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758284 | connmgr] Registering support for 'video/x-zmbv'
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.758561 | webserver] Provide /upnp/grender-64x64.png (image/png) from /usr/local/share/gmediarender/grender-64x64.png
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.761013 | webserver] Provide /upnp/grender-128x128.png (image/png) from /usr/local/share/gmediarender/grender-128x128.png
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.765975 | webserver] Provide /upnp/rendertransportSCPD.xml (text/xml) from buffer
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.767091 | webserver] Provide /upnp/renderconnmgrSCPD.xml (text/xml) from buffer
Jul 14 08:08:30 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:30.769726 | webserver] Provide /upnp/rendercontrolSCPD.xml (text/xml) from buffer
Jul 14 08:08:31 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:31.772123 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (59s)
Jul 14 08:08:32 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:32.773055 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (58s)
Jul 14 08:08:33 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:33.774055 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (57s)
Jul 14 08:08:34 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:34.776127 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (56s)
Jul 14 08:08:35 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:35.778777 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (55s)
Jul 14 08:08:36 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:36.781219 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (54s)
Jul 14 08:08:37 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:37.784186 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (53s)
Jul 14 08:08:38 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:38.786219 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (52s)
Jul 14 08:08:39 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:39.788111 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (51s)
Jul 14 08:08:40 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:40.789949 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (50s)
Jul 14 08:08:41 rasbpi4 gmediarender[500]: ERROR [2021-07-14 08:08:41.791827 | upnp] UpnpInit2(interface=wlan0, port=49494) Error: UPNP_E_INVALID_INTERFACE (-121). Retrying... (49s)
Jul 14 08:08:41 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:41.795728 | upnp] Registered IP=192.168.0.108 port=49494
Jul 14 08:08:41 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:41.905393 | gstreamer] Query volume fraction: 0.316228
Jul 14 08:08:41 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:41.905451 | control] Output initial volume is 0.316228; setting control variables accordingly.
Jul 14 08:08:41 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:41.905488 | control] Setting volume-db to -10.00db == #75
Jul 14 08:08:41 rasbpi4 gmediarender[500]: INFO  [2021-07-14 08:08:41.905761 | main] Ready for rendering.
Jul 14 08:08:41 rasbpi4 gmediarender[500]: Ready for rendering.
hzeller commented 3 years ago

and now you see it listening on Registered IP=192.168.0.108 port=49494 so that is where your upnp-controller will then discover it.

parasange commented 3 years ago

and now you see it listening on Registered IP=192.168.0.108 port=49494 so that is where your upnp-controller will then discover it.

Okay thanks.

But when I do a pulseaudio-dlna --renderer-urls http://192.168.0.108:49494 it gives me a 07-14 09:19:37 pulseaudio_dlna.holder WARNING Could no connect to http://192.168.0.108:49494. Connection timeout.

Restarting the service without rebooting and starting pulseaudio-dlna and it works again. I don't get it :-)

parasange commented 3 years ago

I just added a delay for the service and now it works. My systemd service now looks like

[Unit]
Description=gmrender-resurrect service
Requires=network-online.target sound.target
After=network-online.target sound.target

[Service]
Environment="UPNP_DEVICE_NAME=Rasbpi4"
ExecStartPre=/bin/sh -c "/bin/systemctl set-environment UPNP_UUID=`ip link show | awk '/ether/ {print \"salt:)-\" $2}' | head -1 | md5sum | awk '{print $1}'`"
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/bin/gmediarender -f "$UPNP_DEVICE_NAME" -u "$UPNP_UUID" \
                                      --gstout-audiosink=alsasink --gstout-audiodevice=sysdefault \
                                      --logfile=stdout --interface-name=wlan0 --gstout-initial-volume-db=-10
Restart=always

[Install]
WantedBy=multi-user.target
hzeller commented 3 years ago

Independent of that you now worked around it with a little bit of waiting: In the case of the hanging, connection timeout situation - do you see anything in the logs on the gmrender side ? It should output a message that shows an attempt to connect. But maybe that is not coming through. Then looking on the network with wireshark might bring some insight.