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:
- The I2S has to be available
- 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