1

I have the following systemd service, which starts a systemd service as soon as I boot my raspberrypi:

[Unit]
Description=MyService
DefaultDependencies=false

[Service]
Environment=SERVICE_HOME=/home/pi/myproject
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/myproject
ExecStart=/usr/bin/python /home/pi/myproject/service.py
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=3

[Install]
WantedBy=local-fs.target

I see some LEDs blinking so GPIO is working correctly, however, if I press a button, which starts arecord over I2S then the whole process fails since I2S is not ready.

I did not find a "I2S Ready" as a possible target for the WantedBy section of my service definition.

What I had before was WantedBy=multi-user.target but this would wait until a lot of other services including network and ssh are ready too. I wanted to optimise the boot time of my service, but it seems that local-fs.target is too soon.

Update:

There is more to this problem. I did add the ConditionPathIsReadWrite to the Unit section of my service and it seems that the filesystem is not yet writable.

So the two conditions seem to be that:

  1. The I2S has to be available
  2. The filesystem needs to be writable

This is the output from the status of systemctl:

Condition: start condition failed at Thu 2016-11-03 18:16:43 CET; 3 years 2 months ago
           └─ ConditionPathIsReadWrite=/home/pi/myproject/data was not met
2

You set DefaultDependencies=false. This is a hard condition and I would not do it because you have to define all needed dependencies by yourself. With man systemd.service you will find:

Default Dependencies
The following dependencies are added unless DefaultDependencies=no is set:

• Service units will have dependencies of type Requires= and After= on sysinit.target, a dependency of type After= on basic.target as well as dependencies of type Conflicts= and Before= on shutdown.target. These ensure that normal service units pull in basic system initialization, and are terminated cleanly prior to system shutdown. Only services involved with early boot or late system shutdown should disable this option.

I know you will have your script run at early boot but this is mainly meant to run compiled drivers and programs from an init ramdisk and not a script that needs a complex interpreter (python3) that must be initialized before. If you really want to set DefaultDependencies=no I'm afraid that we cannot help you much because you can only try and error to find the needed essential dependencies for python3 and your script. If you will start into this adventure then a look at freedesktop - bootup may help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.