Server Fault Asked by kalise on November 17, 2020
we have a simple systemd script to start a MineCraft server in a service fashion. The SO is CentOS 7. Here the script:
[Unit]
Description=Minecraft Server
After=syslog.target network.target
[Service]
Type=simple
WorkingDirectory=/root/Minecraft
ExecStart=/bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
Restart=on-failure
[Install]
WantedBy=multi-user.target
Starting the service works fine but when stopping , the service remains in a failed state. See:
systemctl status minecraftd.service
minecraftd.service - Minecraft Server
Loaded: loaded (/usr/lib/systemd/system/minecraftd.service; disabled)
Active: active (running) since Mon 2015-06-01 16:00:12 UTC; 18s ago
Main PID: 20975 (java)
CGroup: /system.slice/minecraftd.service
└─20975 /bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
systemctl stop minecraftd.service
systemctl status minecraftd.service
minecraftd.service - Minecraft Server
Loaded: loaded (/usr/lib/systemd/system/minecraftd.service; disabled)
Active: failed (Result: exit-code) since Mon 2015-06-01 16:01:37 UTC; 3s ago
Process: 20975 ExecStart=/bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui (code=exited, status=143)
Main PID: 20975 (code=exited, status=143)
Any idea?
Thanks
Exit code 143 means that the program received a SIGTERM signal to instruct it to exit. The JVM catches the signal, does a clean shutdown, i.e. it runs all registered shutdown hooks, but still exits with an exit code of 143. That's just how Java works.
You should be able to suppress this by adding the exit code into the unit file as a "success" exit status:
[Service]
SuccessExitStatus=143
Correct answer by Michael Hampton on November 17, 2020
To complement Michael's answer, the exit code 143 is normal here, it is the way that the java VM received a SIGTERM signal, send by systemd to stop the process.
The SIGTERM signal has a numeric value of 15 ( see man signal
).
Now according to the Posix specification, "The exit status of a command that terminated because it received a signal shall be reported as greater than 128". (http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_08_02)
Here the Java VM adds 128 + 15 and you get this exit code of 143.
This non zero exit code here make senses, as this allows to see that your java program exited because of an external signal, and you get a chance to find out which signal.
Answered by Manu on November 17, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP