-2

I am trying to start a service named pigpiod.service via systemd. It invokes a script with three commands. The second one is left out. Why is this?

/etc/systemd/system/pigpiod.service:

[Unit]
Description=Starts pigpiod
Before=touchscreen.service

[Service]
ExecStart=/home/sysop/pigpiod.sh

[Install]
WantedBy=multi-user.target

/home/sysop/pigpiod.sh:

#!/bin/sh

touch /home/sysop/before_pigpiod
/usr/bin/pigpiod
touch /home/sysop/after_pigpiod
  • When restarting the machine the two files get created in /home/sysop/, but pigpiod is not starting.
  • When starting the service manually via sudo systemctl start pigpiod the same happens.
  • When running sudo /home/sysop/pigpiod.sh manually pigpiod is actually starting!

This is the output of sudo systemctl status pigpiod -l right after boot:

● pigpiod.service - Starts pigpiod
   Loaded: loaded (/etc/systemd/system/pigpiod.service; enabled)
   Active: inactive (dead) since Sat 2017-09-16 20:02:03 UTC; 2min 29s ago
  Process: 440 ExecStart=/home/sysop/pigpiod.sh (code=exited, status=0/SUCCESS)
 Main PID: 440 (code=exited, status=0/SUCCESS)

Sep 16 20:02:02 kivypie systemd[1]: Starting Starts pigpiod...
Sep 16 20:02:02 kivypie systemd[1]: Started Starts pigpiod.

Why is it, that systemd skips the execution of /usr/bin/pigpiod, but manually running the script as root does not?

My system: Raspberry Pi Model 3B, Raspbian GNU/Linux 8 (jessie)

303
  • 888
  • 1
  • 11
  • 31
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Sep 18 '17 at 01:33

1 Answers1

-1

pigpiod forks without the -g option. So use Type = forking or use pigpiod -g

[Unit]
Description=Starts pigpiod
Before=touchscreen.service

[Service]
ExecStart=/home/sysop/pigpiod.sh
Type=forking

[Install]
WantedBy=multi-user.target
Nuetrino
  • 1,099
  • 1
  • 14
  • 32