I'm trying to run my app as a daemon/service on a Debian distro via systemd. Here is my service file:
[Unit]
Description=MyApp Service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=sudo /usr/bin/java -jar /home/pi/myapp.jar
[Install]
WantedBy=multi-user.target
I copy that to /lib/systemd/system/myapp.service. I then run:
sudo systemctl enable myapp
I then check the status:
sudo systemctl status myapp
And I see these errors:
● myapp.service - MyApp Service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
Sep 29 09:56:24 raspberrypi systemd[1]: [/lib/systemd/system/myapp.service:8] Executable path is not absolute, ignoring: sudo /usr/bin/java -jar /home/pi/myapp.jar
Sep 29 09:56:24 raspberrypi systemd[1]: myapp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
When I do which java I see:
pi@raspberrypi:/lib/systemd/system $ which java
/usr/bin/java
So I'm not understanding why systemd is complaining about the executable path. Any ideas how I can troubleshoot?