• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Raspbian stretch systemd
#1
Just thought I'd share my experiences with starting pilight with systemd in Raspbian stretch. I am not very experienced with systemd so I am sure there is better ways of doing this. Please feel free to come with suggestions.

My problem i wanted to solve was that pilight started too early in the boot process and thus got the "ERROR: cannot bind to the ssdp multicast network". I'm using the wireless network on a Raspberry Pi 3.

pilight.service
Code:
[Unit]
Description=pilight
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/sbin/pilight-daemon
Type=forking

[Install]
WantedBy=multi-user.target

The key here was to add the line Wants=network-online.target. Without that line the network-online.target was not even brought up by systemd. My thought here is that no other service wanted it so it was ignored.

About the network-online.target itself. It seems that since Raspbian doesn't come with NetworkManager or similar with services to provide the network-online.target you have to roll your own. There is a guy over at the Raspberry pi forums that had a suggestion for Jessie but I couldn't get it to work satisfactory in my setup. Below is my version. Not sure what would be the best here. Mine makes network-online.target wait until dhcpcd has set a default route.

wait-for-route.service
Code:
Description=Wait for route
Documentation=https://www.raspberrypi.org/forums/viewtopic.php?t=187225
DefaultDependencies=no
Wants=network.target
After=local-fs.target network.target apparmor.service systemd-sysctl.service systemd-modules-load.service
Before=shutdown.target network-online.target
Conflicts=shutdown.target

[Install]
WantedBy=network-online.target

[Service]
Type=oneshot
RemainAfterExit=true
TimeoutStartSec=2min
ExecStart=/bin/bash -c " \
   count=0; \
   while [ -z \"$(/sbin/ip route | awk '/default/ { print $3 }')\" ]; \
   do \
       sleep 1s; \
       count=$((count+1)); \
       echo \"Waited for route for $count seconds\"; \
   done;"
 
Reply
#2
Would be great if you push your ideas to a pull-request on our github.
 
Reply
#3
Sure. It looks like the deb package installs both sysv and systemd services. Is there a reason for that? I read that PRs should be made towards the development branch. To get me started I cherry-picked some commits from master. Not sure what you think about that. I haven't test built it yet, this is just to show you my thoughts.

https://github.com/pilight/pilight/compa...evelopment
 
Reply
#4
Yes, because that way we cover it all.

In regard to the commits. I would just like to see the changed you want pushed.
 
Reply
#5
Can you tell me about the cases where the sysv init is still in use? Maybe parse the /etc/os-version file and take action accordingly? I just did a very basic differentiation. The development branch doesn't have pilight.service so that's why i cherry-picked it from master. Also the res/deb folder was missing.
 
Reply
#6
As far as my knowledge of linux goes there is no definitive way to determine the init system used.
 
Reply
#7
I don't understand how to proceed. Like i said pilight.service and res/deb/pilight/* is not i development branch.
 
Reply
#8
You are allowed to push these changes to staging Smile
 
Reply
#9
Great [Image: thumbsup.gif] PR sent.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  pilight for Raspbian Buster (raspberry pi 4) ? starob 30 7,120 52 minutes ago
Last Post: simanuel
  433gpio platform error after raspbian dist upgrade HuberDe 2 750 10-12-2019, 07:35 PM
Last Post: HuberDe
  RPI3 b+ Raspbiam Stretch and pilight-7_oregon Tueftler1983 1 1,460 12-04-2018, 11:59 PM
Last Post: Tueftler1983
  Steps to move from Jessie to Stretch wo_rasp 16 6,510 09-10-2017, 11:03 AM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)