Systemd unit file only works for one instance name, not the other
There are two Minecraft servers running on my Debian server. In order to avoid all the busywork of manually coordinating multiple tmux sessions, I wrote a systemd unit file to do all of that for me:
[Unit]
Description=Minecraft Server: %i
After=network.target
[Service]
WorkingDirectory=/opt/minecraft/servers/%i
User=minecraft
Group=minecraft
Type=forking
RemainAfterExit=yes
#Restart=on-abnormal
ExecStart=/usr/bin/tmux new -s mc-%i -d '/usr/bin/java -Xms1G -Xmx4G -jar forge-universal.jar nogui'
ExecStop=/usr/bin/tmux send -t mc-%i 'say SERVER WILL SHUT DOWN IN 10 SECONDS' ENTER
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/tmux send -t mc-%i 'stop' ENTER
[Install]
WantedBy=multi-user.target
There are two subdirectories in /opt/minecraft/servers/: private and otherserver. These directories' file listings look like this:
minecraft@server ~ # ls -la /opt/minecraft/servers/private/
total 39180
drwxr-xr-x 9 minecraft minecraft 4096 Dec 20 21:34 .
drwxr-xr-x 5 minecraft minecraft 4096 Dec 19 21:11 ..
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-ips.json
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-players.json
drwxr-xr-x 10 minecraft minecraft 4096 Oct 11 16:22 config
drwxr-xr-x 2 minecraft minecraft 4096 Oct 11 16:11 crash-reports
-rw-r--r-- 1 minecraft minecraft 181 Oct 11 16:11 eula.txt
-rw-r--r-- 1 minecraft minecraft 4888981 Oct 11 16:10 forge-1.12.2-14.23.5.2768-universal.jar
lrwxrwxrwx 1 minecraft minecraft 39 Oct 11 11:41 forge-universal.jar -> forge-1.12.2-14.23.5.2768-universal.jar
drwxr-xr-x 3 minecraft minecraft 4096 Apr 14 2018 journeymap
drwxr-xr-x 8 minecraft minecraft 4096 Apr 14 2018 libraries
drwxr-xr-x 2 minecraft minecraft 4096 Dec 20 21:32 logs
-rw-r--r-- 1 minecraft minecraft 369 Oct 11 15:04 mapcrafter.conf
-rw-r--r-- 1 minecraft minecraft 30222121 Oct 11 16:10 minecraft_server.1.12.2.jar
drwxr-xr-x 3 minecraft minecraft 4096 Oct 11 16:21 mods
-rw-r--r-- 1 minecraft minecraft 271 Dec 20 21:33 ops.json
-rw-r--r-- 1 minecraft minecraft 843 Dec 20 21:33 server.properties
-rw-r--r-- 1 minecraft minecraft 322 Dec 20 21:32 usercache.json
-rw-r--r-- 1 minecraft minecraft 112 Oct 13 23:18 usernamecache.json
-rw-r--r-- 1 minecraft minecraft 171 Dec 18 22:07 whitelist.json
drwxr-xr-x 11 minecraft minecraft 4096 Dec 20 21:33 world
Executing systemctl start minecraft@otherserver results in a new tmux session for the user minecraft called mc-otherserver and a successfully started Minecraft server.
Executing systemctl start minecraft@private, on the other hand, does literally nothing. The command returns instantly, does not spawn a new tmux session, doesn't start a new Minecraft server, nothing. I checked whether the Minecraft instance was just crashing, but it's not that. Manually executing tmux new -s mc-private -d 'java -Xms1G -Xmx4G -jar forge-universal.jar nogui in the server's directory works flawlessly and starts the Minecraft server in a new tmux instance, as intended.
Curiously enough, both servers worked just a few days ago. I checked the changelogs for systemd and tmux, but as far as I can tell, they haven't actually been updated for Debian stable for some weeks.
Additionally, journalctl contains no information about my failing unit file at all, so I'm at a loss here. Does anyone know what could be causing this?
automation tmux systemd minecraft
add a comment |
There are two Minecraft servers running on my Debian server. In order to avoid all the busywork of manually coordinating multiple tmux sessions, I wrote a systemd unit file to do all of that for me:
[Unit]
Description=Minecraft Server: %i
After=network.target
[Service]
WorkingDirectory=/opt/minecraft/servers/%i
User=minecraft
Group=minecraft
Type=forking
RemainAfterExit=yes
#Restart=on-abnormal
ExecStart=/usr/bin/tmux new -s mc-%i -d '/usr/bin/java -Xms1G -Xmx4G -jar forge-universal.jar nogui'
ExecStop=/usr/bin/tmux send -t mc-%i 'say SERVER WILL SHUT DOWN IN 10 SECONDS' ENTER
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/tmux send -t mc-%i 'stop' ENTER
[Install]
WantedBy=multi-user.target
There are two subdirectories in /opt/minecraft/servers/: private and otherserver. These directories' file listings look like this:
minecraft@server ~ # ls -la /opt/minecraft/servers/private/
total 39180
drwxr-xr-x 9 minecraft minecraft 4096 Dec 20 21:34 .
drwxr-xr-x 5 minecraft minecraft 4096 Dec 19 21:11 ..
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-ips.json
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-players.json
drwxr-xr-x 10 minecraft minecraft 4096 Oct 11 16:22 config
drwxr-xr-x 2 minecraft minecraft 4096 Oct 11 16:11 crash-reports
-rw-r--r-- 1 minecraft minecraft 181 Oct 11 16:11 eula.txt
-rw-r--r-- 1 minecraft minecraft 4888981 Oct 11 16:10 forge-1.12.2-14.23.5.2768-universal.jar
lrwxrwxrwx 1 minecraft minecraft 39 Oct 11 11:41 forge-universal.jar -> forge-1.12.2-14.23.5.2768-universal.jar
drwxr-xr-x 3 minecraft minecraft 4096 Apr 14 2018 journeymap
drwxr-xr-x 8 minecraft minecraft 4096 Apr 14 2018 libraries
drwxr-xr-x 2 minecraft minecraft 4096 Dec 20 21:32 logs
-rw-r--r-- 1 minecraft minecraft 369 Oct 11 15:04 mapcrafter.conf
-rw-r--r-- 1 minecraft minecraft 30222121 Oct 11 16:10 minecraft_server.1.12.2.jar
drwxr-xr-x 3 minecraft minecraft 4096 Oct 11 16:21 mods
-rw-r--r-- 1 minecraft minecraft 271 Dec 20 21:33 ops.json
-rw-r--r-- 1 minecraft minecraft 843 Dec 20 21:33 server.properties
-rw-r--r-- 1 minecraft minecraft 322 Dec 20 21:32 usercache.json
-rw-r--r-- 1 minecraft minecraft 112 Oct 13 23:18 usernamecache.json
-rw-r--r-- 1 minecraft minecraft 171 Dec 18 22:07 whitelist.json
drwxr-xr-x 11 minecraft minecraft 4096 Dec 20 21:33 world
Executing systemctl start minecraft@otherserver results in a new tmux session for the user minecraft called mc-otherserver and a successfully started Minecraft server.
Executing systemctl start minecraft@private, on the other hand, does literally nothing. The command returns instantly, does not spawn a new tmux session, doesn't start a new Minecraft server, nothing. I checked whether the Minecraft instance was just crashing, but it's not that. Manually executing tmux new -s mc-private -d 'java -Xms1G -Xmx4G -jar forge-universal.jar nogui in the server's directory works flawlessly and starts the Minecraft server in a new tmux instance, as intended.
Curiously enough, both servers worked just a few days ago. I checked the changelogs for systemd and tmux, but as far as I can tell, they haven't actually been updated for Debian stable for some weeks.
Additionally, journalctl contains no information about my failing unit file at all, so I'm at a loss here. Does anyone know what could be causing this?
automation tmux systemd minecraft
add a comment |
There are two Minecraft servers running on my Debian server. In order to avoid all the busywork of manually coordinating multiple tmux sessions, I wrote a systemd unit file to do all of that for me:
[Unit]
Description=Minecraft Server: %i
After=network.target
[Service]
WorkingDirectory=/opt/minecraft/servers/%i
User=minecraft
Group=minecraft
Type=forking
RemainAfterExit=yes
#Restart=on-abnormal
ExecStart=/usr/bin/tmux new -s mc-%i -d '/usr/bin/java -Xms1G -Xmx4G -jar forge-universal.jar nogui'
ExecStop=/usr/bin/tmux send -t mc-%i 'say SERVER WILL SHUT DOWN IN 10 SECONDS' ENTER
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/tmux send -t mc-%i 'stop' ENTER
[Install]
WantedBy=multi-user.target
There are two subdirectories in /opt/minecraft/servers/: private and otherserver. These directories' file listings look like this:
minecraft@server ~ # ls -la /opt/minecraft/servers/private/
total 39180
drwxr-xr-x 9 minecraft minecraft 4096 Dec 20 21:34 .
drwxr-xr-x 5 minecraft minecraft 4096 Dec 19 21:11 ..
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-ips.json
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-players.json
drwxr-xr-x 10 minecraft minecraft 4096 Oct 11 16:22 config
drwxr-xr-x 2 minecraft minecraft 4096 Oct 11 16:11 crash-reports
-rw-r--r-- 1 minecraft minecraft 181 Oct 11 16:11 eula.txt
-rw-r--r-- 1 minecraft minecraft 4888981 Oct 11 16:10 forge-1.12.2-14.23.5.2768-universal.jar
lrwxrwxrwx 1 minecraft minecraft 39 Oct 11 11:41 forge-universal.jar -> forge-1.12.2-14.23.5.2768-universal.jar
drwxr-xr-x 3 minecraft minecraft 4096 Apr 14 2018 journeymap
drwxr-xr-x 8 minecraft minecraft 4096 Apr 14 2018 libraries
drwxr-xr-x 2 minecraft minecraft 4096 Dec 20 21:32 logs
-rw-r--r-- 1 minecraft minecraft 369 Oct 11 15:04 mapcrafter.conf
-rw-r--r-- 1 minecraft minecraft 30222121 Oct 11 16:10 minecraft_server.1.12.2.jar
drwxr-xr-x 3 minecraft minecraft 4096 Oct 11 16:21 mods
-rw-r--r-- 1 minecraft minecraft 271 Dec 20 21:33 ops.json
-rw-r--r-- 1 minecraft minecraft 843 Dec 20 21:33 server.properties
-rw-r--r-- 1 minecraft minecraft 322 Dec 20 21:32 usercache.json
-rw-r--r-- 1 minecraft minecraft 112 Oct 13 23:18 usernamecache.json
-rw-r--r-- 1 minecraft minecraft 171 Dec 18 22:07 whitelist.json
drwxr-xr-x 11 minecraft minecraft 4096 Dec 20 21:33 world
Executing systemctl start minecraft@otherserver results in a new tmux session for the user minecraft called mc-otherserver and a successfully started Minecraft server.
Executing systemctl start minecraft@private, on the other hand, does literally nothing. The command returns instantly, does not spawn a new tmux session, doesn't start a new Minecraft server, nothing. I checked whether the Minecraft instance was just crashing, but it's not that. Manually executing tmux new -s mc-private -d 'java -Xms1G -Xmx4G -jar forge-universal.jar nogui in the server's directory works flawlessly and starts the Minecraft server in a new tmux instance, as intended.
Curiously enough, both servers worked just a few days ago. I checked the changelogs for systemd and tmux, but as far as I can tell, they haven't actually been updated for Debian stable for some weeks.
Additionally, journalctl contains no information about my failing unit file at all, so I'm at a loss here. Does anyone know what could be causing this?
automation tmux systemd minecraft
There are two Minecraft servers running on my Debian server. In order to avoid all the busywork of manually coordinating multiple tmux sessions, I wrote a systemd unit file to do all of that for me:
[Unit]
Description=Minecraft Server: %i
After=network.target
[Service]
WorkingDirectory=/opt/minecraft/servers/%i
User=minecraft
Group=minecraft
Type=forking
RemainAfterExit=yes
#Restart=on-abnormal
ExecStart=/usr/bin/tmux new -s mc-%i -d '/usr/bin/java -Xms1G -Xmx4G -jar forge-universal.jar nogui'
ExecStop=/usr/bin/tmux send -t mc-%i 'say SERVER WILL SHUT DOWN IN 10 SECONDS' ENTER
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/tmux send -t mc-%i 'stop' ENTER
[Install]
WantedBy=multi-user.target
There are two subdirectories in /opt/minecraft/servers/: private and otherserver. These directories' file listings look like this:
minecraft@server ~ # ls -la /opt/minecraft/servers/private/
total 39180
drwxr-xr-x 9 minecraft minecraft 4096 Dec 20 21:34 .
drwxr-xr-x 5 minecraft minecraft 4096 Dec 19 21:11 ..
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-ips.json
-rw-r--r-- 1 minecraft minecraft 2 Dec 20 21:33 banned-players.json
drwxr-xr-x 10 minecraft minecraft 4096 Oct 11 16:22 config
drwxr-xr-x 2 minecraft minecraft 4096 Oct 11 16:11 crash-reports
-rw-r--r-- 1 minecraft minecraft 181 Oct 11 16:11 eula.txt
-rw-r--r-- 1 minecraft minecraft 4888981 Oct 11 16:10 forge-1.12.2-14.23.5.2768-universal.jar
lrwxrwxrwx 1 minecraft minecraft 39 Oct 11 11:41 forge-universal.jar -> forge-1.12.2-14.23.5.2768-universal.jar
drwxr-xr-x 3 minecraft minecraft 4096 Apr 14 2018 journeymap
drwxr-xr-x 8 minecraft minecraft 4096 Apr 14 2018 libraries
drwxr-xr-x 2 minecraft minecraft 4096 Dec 20 21:32 logs
-rw-r--r-- 1 minecraft minecraft 369 Oct 11 15:04 mapcrafter.conf
-rw-r--r-- 1 minecraft minecraft 30222121 Oct 11 16:10 minecraft_server.1.12.2.jar
drwxr-xr-x 3 minecraft minecraft 4096 Oct 11 16:21 mods
-rw-r--r-- 1 minecraft minecraft 271 Dec 20 21:33 ops.json
-rw-r--r-- 1 minecraft minecraft 843 Dec 20 21:33 server.properties
-rw-r--r-- 1 minecraft minecraft 322 Dec 20 21:32 usercache.json
-rw-r--r-- 1 minecraft minecraft 112 Oct 13 23:18 usernamecache.json
-rw-r--r-- 1 minecraft minecraft 171 Dec 18 22:07 whitelist.json
drwxr-xr-x 11 minecraft minecraft 4096 Dec 20 21:33 world
Executing systemctl start minecraft@otherserver results in a new tmux session for the user minecraft called mc-otherserver and a successfully started Minecraft server.
Executing systemctl start minecraft@private, on the other hand, does literally nothing. The command returns instantly, does not spawn a new tmux session, doesn't start a new Minecraft server, nothing. I checked whether the Minecraft instance was just crashing, but it's not that. Manually executing tmux new -s mc-private -d 'java -Xms1G -Xmx4G -jar forge-universal.jar nogui in the server's directory works flawlessly and starts the Minecraft server in a new tmux instance, as intended.
Curiously enough, both servers worked just a few days ago. I checked the changelogs for systemd and tmux, but as far as I can tell, they haven't actually been updated for Debian stable for some weeks.
Additionally, journalctl contains no information about my failing unit file at all, so I'm at a loss here. Does anyone know what could be causing this?
automation tmux systemd minecraft
automation tmux systemd minecraft
asked Dec 20 '18 at 22:10
Peter W.Peter W.
4872619
4872619
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Sigh. Turns out the minecraft@private service was listed as loaded failed failed in systemctl list-units, and was thus prevented from being started again.
Doing systemctl reset-failed fixed my problem.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2fsuperuser.com%2fquestions%2f1386458%2fsystemd-unit-file-only-works-for-one-instance-name-not-the-other%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sigh. Turns out the minecraft@private service was listed as loaded failed failed in systemctl list-units, and was thus prevented from being started again.
Doing systemctl reset-failed fixed my problem.
add a comment |
Sigh. Turns out the minecraft@private service was listed as loaded failed failed in systemctl list-units, and was thus prevented from being started again.
Doing systemctl reset-failed fixed my problem.
add a comment |
Sigh. Turns out the minecraft@private service was listed as loaded failed failed in systemctl list-units, and was thus prevented from being started again.
Doing systemctl reset-failed fixed my problem.
Sigh. Turns out the minecraft@private service was listed as loaded failed failed in systemctl list-units, and was thus prevented from being started again.
Doing systemctl reset-failed fixed my problem.
answered Dec 21 '18 at 8:49
Peter W.Peter W.
4872619
4872619
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2fsuperuser.com%2fquestions%2f1386458%2fsystemd-unit-file-only-works-for-one-instance-name-not-the-other%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