Kodi Community Forum

Full Version: Included kodi.service starts before network is ready on Raspberry Pi 3B+/wireless
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Problem: When kodi.service is enabled at boot time, kodi starts before the network is up and thus cannot connect to mysql.
Work around: ssh into the RPi and manually stop kodi.service and manually start kodi.service after it boots.

Details: I want to use systemd-networkd and wpa_supplicant to manage the network.  I want to retain the option to plugin a physical cable to eth0 if I need to but generally, only wireless networking will be used unless something breaks and needs manual intervention.  As such, I created 2 files in /etc/systemd/network/ shown below.

Question: Is there a modification to kodi.service to cause it to wait for the wireless network to be ready ie via Requires= or Wants= for just the wireless network (see this reference)? When I add After=network-online.target andWants=network-online.target to kodi.service, kodi start up is delayed by 2 min (the default timeout I guess).

Is there a better configuration to systemd-networkd to prevent this?
Code:
% cat /etc/systemd/network/10-wire.network
[Match]
Name=eth0
[Network]
DHCP=ipv4
[DHCP]
RouteMetric=10
 
Code:
% cat /etc/systemd/network/20-wireless.network
[Match]
Name=wlan0
[Network]
DHCP=ipv4
[DHCP]
RouteMetric=20
Ah... I found systemd#5154.  Perhaps the solution is two fold:

1) Copy /usr/lib/systemd/system/kodi.service to /etc/systemd/system/ and modify it as follows:
Code:
-After=remote-fs.target
+After=remote-fs.target network-online.target
+Wants=network-online.target

2) Copy /usr/lib/systemd/system/systemd-networkd-wait-online.service to /etc/systemd/system/ and modify it as follows:
Code:
-ExecStart=/usr/lib/systemd/systemd-networkd-wait-online
+ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --ignore eth0

Seems kind of hackish... you guys have any other thoughts?  Thanks!
Which OS are you using on the RPi3B+ ?
(2018-04-21, 16:12)Klojum Wrote: [ -> ]Which OS are you using on the RPi3B+ ?
 Sorry, should have mentioned: Arch ARM (armv7h).
Is this a dedicated Kodi device or are you using it for something else?
(2018-04-22, 01:20)speedwell68 Wrote: [ -> ]Is this a dedicated Kodi device or are you using it for something else?
 Dedicated.
Why not use LibreELEC?  You can set the time to wait for the network in the LibreELEC settings.  I had this issue with my Raspberry Pi Model Bs.
(2018-04-22, 15:32)speedwell68 Wrote: [ -> ]Why not use LibreELEC?  You can set the time to wait for the network in the LibreELEC settings.  I had this issue with my Raspberry Pi Model Bs.
 I prefer Arch ARM.  The solution I outlined above works as expected (updated arch wiki.  Just wondering if there is another way for users of systemd.
(2018-04-21, 16:05)graysky Wrote: [ -> ]Seems kind of hackish... you guys have any other thoughts?  Thanks! 
 I don't think this is hackish, this seems to be the proper systemd-way.
 I can't think of another way atm.
 I use the same approach but for wired eth (without changing systemd-networkd-wait-online.service) because I need the network and nfs os mount up and running before kodi starts
The correct way is to use a systemd dropin.
This allows you to only override changes you need and therefore track changes upstream more easily
(2018-04-22, 23:46)Sam.Nazarko Wrote: [ -> ]The correct way is to use a systemd dropin.
This allows you to only override changes you need and therefore track changes upstream more easily
 Example?
(2018-04-23, 18:51)Sam.Nazarko Wrote: [ -> ]See https://github.com/osmc/osmc/blob/master...local.conf
 Thank you for the link.  I read-up on 'systemd drop-in' files which I think is what you're describing.  Edited the wiki again.