Closed andrewdavidmackenzie closed 8 months ago
What is the raspberry pi OS these days? Is it still Debian? Does that use systemd?
You can check what is created for systemd at /etc/systemd/system/{your-app}.service
for a globally-installed service. You could also try the user-level variant to see if that works instead.
You should also check the status of your service using systemctl
to see if it failed, or just wasn't started, or maybe not detected.
I was already trying as user-level service. I had to first enable "lingering" for the service to outlive the user who started it.
But I don't see anything of mine in "/etc/systemd/system/"
Removeing the user-level code to go back to system-level, I get this error:
Error: Custom { kind: Other, error:
"Failed to start mackenzie-service-pingr.wimon.service: Unit mackenzie-service-pingr.wimon.service
has a bad unit file setting.\nSee system logs and 'systemctl status mackenzie-service-pingr.wimon.service'
for details.\n" }
running systemctl:
systemctl status mackenzie-service-pingr.wimon.service
● mackenzie-service-pingr.wimon.service - mackenzie-service-pingr.wimon
Loaded: bad-setting (Reason: Unit mackenzie-service-pingr.wimon.service has a bad unit file setting.)
Active: inactive (dead)
Jan 18 19:42:33 pizerow0 systemd[1]: /etc/systemd/system/mackenzie-service-pingr.wimon.service:4: WorkingDirec>
Jan 18 19:42:33 pizerow0 systemd[1]: mackenzie-service-pingr.wimon.service: Unit configuration has fatal error>
makes it look like working directory is a problem.
I tried copying binary to "/" and running from there, ang get:
sudo ./wimon install
Error: Custom { kind: Other, error: "Failed to enable unit: \"multi-user.target]\" is not a valid unit name.\n" }
I will continue investigating, but any hints welcome.
Can you share the complete generated service file?
Where can I find the service file? (sorry, not familiar at all with this crate or systemd :-( )
Found the problem, and it's mine (no surprises there!). It was the use of non-absolute paths to the exec file and the WD. Solved with a call to canonicalize(). Thanks for your help.
Sorry, spoke too soon:
systemctl status mackenzie-serres-pingr.wimon.service
● mackenzie-serres-pingr.wimon.service - mackenzie-serres-pingr.wimon
Loaded: loaded (/etc/systemd/system/mackenzie-serres-pingr.wimon.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2024-01-19 12:32:53 CET; 8min ago
Process: 645 ExecStart=/home/andrew/workspace/pingr/target/debug/wimon (code=exited, status=1/FAILURE)
Main PID: 645 (code=exited, status=1/FAILURE)
CPU: 64ms
Jan 19 12:32:53 raspberrypi systemd[1]: mackenzie-serres-pingr.wimon.service: Scheduled restart job, restart counter is at 5.
Jan 19 12:32:53 raspberrypi systemd[1]: Stopped mackenzie-serres-pingr.wimon.
Jan 19 12:32:53 raspberrypi systemd[1]: mackenzie-serres-pingr.wimon.service: Start request repeated too quickly.
Jan 19 12:32:53 raspberrypi systemd[1]: mackenzie-serres-pingr.wimon.service: Failed with result 'exit-code'.
Jan 19 12:32:53 raspberrypi systemd[1]: Failed to start mackenzie-serres-pingr.wimon.
and
more /etc/systemd/system/mackenzie-serres-pingr.wimon.service
[Unit]
Description=mackenzie-serres-pingr.wimon
[Service]
WorkingDirectory=/home/andrew/workspace/pingr/target/debug
ExecStart=/home/andrew/workspace/pingr/target/debug/wimon
Restart=on-failure
[Install]
WantedBy=multi-user.target
Could it be that systemd is starting (and restarting) it before other services that it needs are up and running?
I assume that this is just an issue with my binary and systemd, and nothing to do with service-manager, so will close. Any experience or hints welcome though.
Thanks for writing this.
When I install as a service and start it, on Raspberry Pi OS on my Pi400, it runs fine in background.
But when I reboot, it does not seem to re-start.
thanks!