Starting and stopping a headless server using Systemd service

I'm running a fabric server on an Oracle cloud vm running oracle linux. The server is managed by a daemon user and a systemd service. I can start the server fine using sudo systemctl start minecraft-server, but when I stop, it gives me an error in the log:
stop.sh: Error: connection failed (localhost).
systemd: minecraft-server.service: Control process exited, code=exited status=255
systemd: minecraft-server.service: Failed with result 'exit-code'
stop.sh: Error: connection failed (localhost).
systemd: minecraft-server.service: Control process exited, code=exited status=255
systemd: minecraft-server.service: Failed with result 'exit-code'
It then proceeds to stop, despite the error implying that it couldn't. My server starts by running the command: java -Xmx6G -jar fabric-server.jar nogui in a bash script called start.sh. It is stopped by running <absolute_path>/mcrcon -c -H localhost -P <port> -p $RCON_PASSWORD stop in a bash script called stop.sh. Is there a more graceful way to start and stop the server that I'm not aware of? EDIT: Turns out the server does not stop. The log says it does, but the process is still running in the background.
4 Replies
Admincraft Meta
Admincraft Meta8mo ago
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close !close !solved !answered
Requested by swalloich#0
ProGamingDk
ProGamingDk8mo ago
tbh use docker etc, more isolation, makes stopping and starting easier, etc and oracle linux is pretty horrendus tbh would recommend switching if at all possible
swalloich
swalloichOP8mo ago
well, its already running fine on oracle linux, so I'm just gonna keep it that way. How does docker make starting and stopping easier?
ProGamingDk
ProGamingDk8mo ago
well, you can use a panel like pterodactyl that is essentially a frontend for docker, docker might not make starting easier, will make stopping it just docker stop (docker id) would add a layer of isolation, helping reducing damage caused by plugins with malware, exploits (like if another log4j happens, or bleeding pipe rce for forge)

Did you find this page helpful?