I've created a service that runs a Bluetooth server application and is started like this:
[Unit] After=bluetooth.service Requires=bluetooth.service [Service] Type=simple ExecStartPre=/usr/bin/sdptool add SP ExecStartPre=/bin/sleep 0.5 ExecStartPre=/bin/hciconfig hci0 piscan ExecStart=/usr/local/bin/my-service.py ExecStartPost=/usr/bin/bluetoothctl discoverable on Restart=always RestartSec=15 [Install] WantedBy=multi-user.target When I look at the logs for this unit after a system boot, I always see the first start failed and the second succeeds. When looking at the full log, I see that my service is started first, then fails, and later only the bluetooth service is started. My service is retried after that and then the required dependencies are there.
Why does Systemd ignore the After and Requires options in my service?
I've read other web texts, man pages and questions here that suggest using exactly these options for my task. But it's not working for me.
The device is a Raspberry Pi 3B+ with Raspbian OS, Linux kernel 5.4.51 and Systemd 241.
bluetooth.servicestarts successfully the first time around. If the bluetooth service fails then so will your service