Systemd runs start and stop commands simultaneously on Ubuntu 18.04 - Minecraft server issues
up vote
0
down vote
favorite
Update:
Still having this issue. I notice that my systemd service is running both ExecStart and ExecStop commands sequentially when I run "systemctl start minecraft.service". I have verified this from the output from the tmux console and the systemd status as seen below. So it is properly calling the mc_server.sh script, but I can't get it to stop calling the "ExecStop" command. I've tried removing the Type= setting (making it simple by default), directly changing Type to simple, but none of these seem to fix the problem.
Original question:
I recently upgraded to 18.04.1 and am having trouble getting my Minecraft systemd service working again. I did a clean install of 18.04 from 16.04. This service was working properly on 16.04, but now it doesn't seem to work. When I run "systemctl start minecraft.service" it seems to run the ExecStart script and the ExecStop script together based on the status output below, but I do not see any output from the scripts in my tmux console that it should be running through. If I call the startup script manually, it works fine, so something is wrong in the systemd service.
The service is set to run as the minecraft user under minecraft group. Everything in /srv/minecraft is owned by minecraft user/group. The minecraft.service file is owned by root. All of this is the same as it was in 16.04 when it was working. Please let me know if you have any ideas to get it running again! Thanks!!
:/etc/systemd/system$ systemctl status minecraft.service
● minecraft.service - Minecraft Server
Loaded: loaded (/etc/systemd/system/minecraft.service; enabled; vendor
preset
Active: inactive (dead) since Wed 2018-11-14 16:33:25 PST; 3s ago
Process: 4667 ExecStop=/srv/minecraft/mc_server.sh stop (code=exited,
status=0/SUCCESS)
Process: 4651 ExecStart=/srv/minecraft/mc_server.sh start (code=exited,
status=0/SUCCESS)
Nov 14 16:33:11 systemd[1]: Starting Minecraft Server...
Nov 14 16:33:11 mc_server.sh[4651]: Session found. Connecting.
Nov 14 16:33:11 mc_server.sh[4651]: Minecraft server successfully
started
Nov 14 16:33:11 mc_server.sh[4667]: step 1 successs
Nov 14 16:33:19 mc_server.sh[4667]: step 2 success
Nov 14 16:33:21 mc_server.sh[4667]: server shutdown success
Nov 14 16:33:25 systemd[1]: Started Minecraft Server.
Here is the systemd script:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target auditd.service
[Service]
WorkingDirectory=/srv/minecraft/
# PrivateUsers=true
User=minecraft
Group=minecraft
ProtectSystem=full
ProtectHome=true
# ProtectKernelTunables=true
# Implies MountFlags=slave
# ProtectKernelModules=true
# Implies NoNewPrivileges=yes
# ProtectControlGroups=true
# Implies MountAPIVFS=yes
Type=forking
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
Restart=on-abnormal
RestartSec=60s
[Install]
WantedBy=multi-user.target
server 18.04 scripts systemd minecraft
add a comment |
up vote
0
down vote
favorite
Update:
Still having this issue. I notice that my systemd service is running both ExecStart and ExecStop commands sequentially when I run "systemctl start minecraft.service". I have verified this from the output from the tmux console and the systemd status as seen below. So it is properly calling the mc_server.sh script, but I can't get it to stop calling the "ExecStop" command. I've tried removing the Type= setting (making it simple by default), directly changing Type to simple, but none of these seem to fix the problem.
Original question:
I recently upgraded to 18.04.1 and am having trouble getting my Minecraft systemd service working again. I did a clean install of 18.04 from 16.04. This service was working properly on 16.04, but now it doesn't seem to work. When I run "systemctl start minecraft.service" it seems to run the ExecStart script and the ExecStop script together based on the status output below, but I do not see any output from the scripts in my tmux console that it should be running through. If I call the startup script manually, it works fine, so something is wrong in the systemd service.
The service is set to run as the minecraft user under minecraft group. Everything in /srv/minecraft is owned by minecraft user/group. The minecraft.service file is owned by root. All of this is the same as it was in 16.04 when it was working. Please let me know if you have any ideas to get it running again! Thanks!!
:/etc/systemd/system$ systemctl status minecraft.service
● minecraft.service - Minecraft Server
Loaded: loaded (/etc/systemd/system/minecraft.service; enabled; vendor
preset
Active: inactive (dead) since Wed 2018-11-14 16:33:25 PST; 3s ago
Process: 4667 ExecStop=/srv/minecraft/mc_server.sh stop (code=exited,
status=0/SUCCESS)
Process: 4651 ExecStart=/srv/minecraft/mc_server.sh start (code=exited,
status=0/SUCCESS)
Nov 14 16:33:11 systemd[1]: Starting Minecraft Server...
Nov 14 16:33:11 mc_server.sh[4651]: Session found. Connecting.
Nov 14 16:33:11 mc_server.sh[4651]: Minecraft server successfully
started
Nov 14 16:33:11 mc_server.sh[4667]: step 1 successs
Nov 14 16:33:19 mc_server.sh[4667]: step 2 success
Nov 14 16:33:21 mc_server.sh[4667]: server shutdown success
Nov 14 16:33:25 systemd[1]: Started Minecraft Server.
Here is the systemd script:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target auditd.service
[Service]
WorkingDirectory=/srv/minecraft/
# PrivateUsers=true
User=minecraft
Group=minecraft
ProtectSystem=full
ProtectHome=true
# ProtectKernelTunables=true
# Implies MountFlags=slave
# ProtectKernelModules=true
# Implies NoNewPrivileges=yes
# ProtectControlGroups=true
# Implies MountAPIVFS=yes
Type=forking
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
Restart=on-abnormal
RestartSec=60s
[Install]
WantedBy=multi-user.target
server 18.04 scripts systemd minecraft
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Update:
Still having this issue. I notice that my systemd service is running both ExecStart and ExecStop commands sequentially when I run "systemctl start minecraft.service". I have verified this from the output from the tmux console and the systemd status as seen below. So it is properly calling the mc_server.sh script, but I can't get it to stop calling the "ExecStop" command. I've tried removing the Type= setting (making it simple by default), directly changing Type to simple, but none of these seem to fix the problem.
Original question:
I recently upgraded to 18.04.1 and am having trouble getting my Minecraft systemd service working again. I did a clean install of 18.04 from 16.04. This service was working properly on 16.04, but now it doesn't seem to work. When I run "systemctl start minecraft.service" it seems to run the ExecStart script and the ExecStop script together based on the status output below, but I do not see any output from the scripts in my tmux console that it should be running through. If I call the startup script manually, it works fine, so something is wrong in the systemd service.
The service is set to run as the minecraft user under minecraft group. Everything in /srv/minecraft is owned by minecraft user/group. The minecraft.service file is owned by root. All of this is the same as it was in 16.04 when it was working. Please let me know if you have any ideas to get it running again! Thanks!!
:/etc/systemd/system$ systemctl status minecraft.service
● minecraft.service - Minecraft Server
Loaded: loaded (/etc/systemd/system/minecraft.service; enabled; vendor
preset
Active: inactive (dead) since Wed 2018-11-14 16:33:25 PST; 3s ago
Process: 4667 ExecStop=/srv/minecraft/mc_server.sh stop (code=exited,
status=0/SUCCESS)
Process: 4651 ExecStart=/srv/minecraft/mc_server.sh start (code=exited,
status=0/SUCCESS)
Nov 14 16:33:11 systemd[1]: Starting Minecraft Server...
Nov 14 16:33:11 mc_server.sh[4651]: Session found. Connecting.
Nov 14 16:33:11 mc_server.sh[4651]: Minecraft server successfully
started
Nov 14 16:33:11 mc_server.sh[4667]: step 1 successs
Nov 14 16:33:19 mc_server.sh[4667]: step 2 success
Nov 14 16:33:21 mc_server.sh[4667]: server shutdown success
Nov 14 16:33:25 systemd[1]: Started Minecraft Server.
Here is the systemd script:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target auditd.service
[Service]
WorkingDirectory=/srv/minecraft/
# PrivateUsers=true
User=minecraft
Group=minecraft
ProtectSystem=full
ProtectHome=true
# ProtectKernelTunables=true
# Implies MountFlags=slave
# ProtectKernelModules=true
# Implies NoNewPrivileges=yes
# ProtectControlGroups=true
# Implies MountAPIVFS=yes
Type=forking
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
Restart=on-abnormal
RestartSec=60s
[Install]
WantedBy=multi-user.target
server 18.04 scripts systemd minecraft
Update:
Still having this issue. I notice that my systemd service is running both ExecStart and ExecStop commands sequentially when I run "systemctl start minecraft.service". I have verified this from the output from the tmux console and the systemd status as seen below. So it is properly calling the mc_server.sh script, but I can't get it to stop calling the "ExecStop" command. I've tried removing the Type= setting (making it simple by default), directly changing Type to simple, but none of these seem to fix the problem.
Original question:
I recently upgraded to 18.04.1 and am having trouble getting my Minecraft systemd service working again. I did a clean install of 18.04 from 16.04. This service was working properly on 16.04, but now it doesn't seem to work. When I run "systemctl start minecraft.service" it seems to run the ExecStart script and the ExecStop script together based on the status output below, but I do not see any output from the scripts in my tmux console that it should be running through. If I call the startup script manually, it works fine, so something is wrong in the systemd service.
The service is set to run as the minecraft user under minecraft group. Everything in /srv/minecraft is owned by minecraft user/group. The minecraft.service file is owned by root. All of this is the same as it was in 16.04 when it was working. Please let me know if you have any ideas to get it running again! Thanks!!
:/etc/systemd/system$ systemctl status minecraft.service
● minecraft.service - Minecraft Server
Loaded: loaded (/etc/systemd/system/minecraft.service; enabled; vendor
preset
Active: inactive (dead) since Wed 2018-11-14 16:33:25 PST; 3s ago
Process: 4667 ExecStop=/srv/minecraft/mc_server.sh stop (code=exited,
status=0/SUCCESS)
Process: 4651 ExecStart=/srv/minecraft/mc_server.sh start (code=exited,
status=0/SUCCESS)
Nov 14 16:33:11 systemd[1]: Starting Minecraft Server...
Nov 14 16:33:11 mc_server.sh[4651]: Session found. Connecting.
Nov 14 16:33:11 mc_server.sh[4651]: Minecraft server successfully
started
Nov 14 16:33:11 mc_server.sh[4667]: step 1 successs
Nov 14 16:33:19 mc_server.sh[4667]: step 2 success
Nov 14 16:33:21 mc_server.sh[4667]: server shutdown success
Nov 14 16:33:25 systemd[1]: Started Minecraft Server.
Here is the systemd script:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target auditd.service
[Service]
WorkingDirectory=/srv/minecraft/
# PrivateUsers=true
User=minecraft
Group=minecraft
ProtectSystem=full
ProtectHome=true
# ProtectKernelTunables=true
# Implies MountFlags=slave
# ProtectKernelModules=true
# Implies NoNewPrivileges=yes
# ProtectControlGroups=true
# Implies MountAPIVFS=yes
Type=forking
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
Restart=on-abnormal
RestartSec=60s
[Install]
WantedBy=multi-user.target
server 18.04 scripts systemd minecraft
server 18.04 scripts systemd minecraft
edited Nov 21 at 21:32
asked Nov 15 at 0:50
MysticEagle
184
184
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Ok, I figured it out. So here's what I did to get this service working again.
Add directive "RemainAfterExit=yes" seemed to solve the problem of the ExecStop command being run right after the startup command. This is a bit strange because in 16.04 with the same setup I didn't need the RemainAfterExit option when the Type was set to forking. But apparently now you need it?
In case anyone is having a similar issue, here is my current systemd Unit file:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=~
Type=simple
RemainAfterExit=yes
PIDFile=/srv/minecraft/minecraft_process.pid
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
[Install]
WantedBy=multi-user.target
add a comment |
up vote
0
down vote
This might not be your systemd but might be the script it is calling that is having trouble.
/srv/minecraft/mc_server.sh
Have you tried running this directly and does that work?
Normally this should work, as I did not get to see your script calling tmux, this is what it should look like.
tmux new -s my_session
run your command to start the server
tmux detach
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Ok, I figured it out. So here's what I did to get this service working again.
Add directive "RemainAfterExit=yes" seemed to solve the problem of the ExecStop command being run right after the startup command. This is a bit strange because in 16.04 with the same setup I didn't need the RemainAfterExit option when the Type was set to forking. But apparently now you need it?
In case anyone is having a similar issue, here is my current systemd Unit file:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=~
Type=simple
RemainAfterExit=yes
PIDFile=/srv/minecraft/minecraft_process.pid
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
[Install]
WantedBy=multi-user.target
add a comment |
up vote
0
down vote
accepted
Ok, I figured it out. So here's what I did to get this service working again.
Add directive "RemainAfterExit=yes" seemed to solve the problem of the ExecStop command being run right after the startup command. This is a bit strange because in 16.04 with the same setup I didn't need the RemainAfterExit option when the Type was set to forking. But apparently now you need it?
In case anyone is having a similar issue, here is my current systemd Unit file:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=~
Type=simple
RemainAfterExit=yes
PIDFile=/srv/minecraft/minecraft_process.pid
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
[Install]
WantedBy=multi-user.target
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Ok, I figured it out. So here's what I did to get this service working again.
Add directive "RemainAfterExit=yes" seemed to solve the problem of the ExecStop command being run right after the startup command. This is a bit strange because in 16.04 with the same setup I didn't need the RemainAfterExit option when the Type was set to forking. But apparently now you need it?
In case anyone is having a similar issue, here is my current systemd Unit file:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=~
Type=simple
RemainAfterExit=yes
PIDFile=/srv/minecraft/minecraft_process.pid
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
[Install]
WantedBy=multi-user.target
Ok, I figured it out. So here's what I did to get this service working again.
Add directive "RemainAfterExit=yes" seemed to solve the problem of the ExecStop command being run right after the startup command. This is a bit strange because in 16.04 with the same setup I didn't need the RemainAfterExit option when the Type was set to forking. But apparently now you need it?
In case anyone is having a similar issue, here is my current systemd Unit file:
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=~
Type=simple
RemainAfterExit=yes
PIDFile=/srv/minecraft/minecraft_process.pid
ExecStart=/srv/minecraft/mc_server.sh start
ExecStop=/srv/minecraft/mc_server.sh stop
[Install]
WantedBy=multi-user.target
answered Nov 22 at 21:38
MysticEagle
184
184
add a comment |
add a comment |
up vote
0
down vote
This might not be your systemd but might be the script it is calling that is having trouble.
/srv/minecraft/mc_server.sh
Have you tried running this directly and does that work?
Normally this should work, as I did not get to see your script calling tmux, this is what it should look like.
tmux new -s my_session
run your command to start the server
tmux detach
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
add a comment |
up vote
0
down vote
This might not be your systemd but might be the script it is calling that is having trouble.
/srv/minecraft/mc_server.sh
Have you tried running this directly and does that work?
Normally this should work, as I did not get to see your script calling tmux, this is what it should look like.
tmux new -s my_session
run your command to start the server
tmux detach
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
add a comment |
up vote
0
down vote
up vote
0
down vote
This might not be your systemd but might be the script it is calling that is having trouble.
/srv/minecraft/mc_server.sh
Have you tried running this directly and does that work?
Normally this should work, as I did not get to see your script calling tmux, this is what it should look like.
tmux new -s my_session
run your command to start the server
tmux detach
This might not be your systemd but might be the script it is calling that is having trouble.
/srv/minecraft/mc_server.sh
Have you tried running this directly and does that work?
Normally this should work, as I did not get to see your script calling tmux, this is what it should look like.
tmux new -s my_session
run your command to start the server
tmux detach
edited 2 days ago
answered Nov 18 at 1:07
Steffen
263
263
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
add a comment |
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
Yes, that's what I meant by calling the startup script manually. Sorry if that was unclear. So I can run that script with the "start" option appended and it works as it should, which is to start the program in a tmux console. It's just not working when I try the systemd service. Also, I made another systemd service for a different program just to make sure I could do it (type=simple) and that one works properly. I'm thinking there may be a permission issue somewhere?
– MysticEagle
Nov 19 at 20:25
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1093040%2fsystemd-runs-start-and-stop-commands-simultaneously-on-ubuntu-18-04-minecraft%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown