systemd: Service lacks both ExecStart= and ExecStop= setting. Refusing

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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?
debian systemd services daemon
add a comment |Â
up vote
0
down vote
favorite
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?
debian systemd services daemon
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
debian systemd services daemon
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?
debian systemd services daemon
debian systemd services daemon
asked Sep 29 '17 at 10:02
smeeb
12516
12516
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.
EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:
AmbientCapabilities=CAP_SYS_RAWIO
User=nobody
the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.
EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:
AmbientCapabilities=CAP_SYS_RAWIO
User=nobody
the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.
add a comment |Â
up vote
3
down vote
accepted
The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.
EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:
AmbientCapabilities=CAP_SYS_RAWIO
User=nobody
the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.
EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:
AmbientCapabilities=CAP_SYS_RAWIO
User=nobody
the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.
The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.
EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:
AmbientCapabilities=CAP_SYS_RAWIO
User=nobody
the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.
edited Sep 30 '17 at 10:49
answered Sep 29 '17 at 10:15
Johan Myréen
6,94711423
6,94711423
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395131%2fsystemd-service-lacks-both-execstart-and-execstop-setting-refusing%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password