LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-01-2020, 08:37 PM   #1
TheJooomes
Member
 
Registered: May 2019
Posts: 190

Rep: Reputation: Disabled
Minecraft server as systemd service, server keeps closing, no logs being generated


I'm following this guide on how to setup a Minecraft server to run as a systemd service. I finally (sorta) think I know what I'm doing now, since I'm new to systemd scripting. My problem is when "systemctl start minecraft@bukkit" is run, it will begin consuming resources, seen in htop, and then after a few seconds all the server stuff just closes. I went to go check the bukkit folder for logs, there are no logs to be found, nothing in ./logs/, nothing in ./crash-reports/.

This is my modified script based on the one in the tutorial: https://pastebin.com/CSNR3vV8


EDIT, NEW DEVELOPMENT IN SOLVING THE PROBLEM:"journalctl -u minecraft@bukkit" gives this, this is now an issue of screens.
Code:
Apr 01 18:11:19 ubuntu systemd[1]: Started Minecraft Server bukkit.
Apr 01 18:11:19 ubuntu screen[15687]: No screen session found.
Apr 01 18:11:19 ubuntu systemd[1]: minecraft@bukkit.service: Control process exited, code=exited status=1
Apr 01 18:11:19 ubuntu systemd[1]: minecraft@bukkit.service: Failed with result 'exit-code'.
Apr 01 18:12:19 ubuntu systemd[1]: minecraft@bukkit.service: Service hold-off time over, scheduling restart.
Apr 01 18:12:19 ubuntu systemd[1]: minecraft@bukkit.service: Scheduled restart job, restart counter is at 5.

Last edited by TheJooomes; 04-02-2020 at 12:41 AM.
 
Old 04-01-2020, 08:41 PM   #2
kermitdafrog8
Member
 
Registered: Dec 2018
Location: Orlando, FL
Distribution: Slackware AARCH64 and X86_64
Posts: 334

Rep: Reputation: Disabled
Minecraft server as systemd service, server keeps closing, no logs being generated

Does it run fine without the systemd service?
 
Old 04-01-2020, 08:50 PM   #3
TheJooomes
Member
 
Registered: May 2019
Posts: 190

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kermitdafrog8 View Post
Does it run fine without the systemd service?
Yes, it runs perfectly fine on it's own. And it will generate logs this way too.
 
Old 04-02-2020, 02:25 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by TheJooomes View Post
this is now an issue of screens.
Code:
Apr 01 18:11:19 ubuntu systemd[1]: Started Minecraft Server bukkit.
Apr 01 18:11:19 ubuntu screen[15687]: No screen session found.
Apr 01 18:11:19 ubuntu systemd[1]: minecraft@bukkit.service: Control process exited, code=exited status=1
Apr 01 18:11:19 ubuntu systemd[1]: minecraft@bukkit.service: Failed with result 'exit-code'.
Apr 01 18:12:19 ubuntu systemd[1]: minecraft@bukkit.service: Service hold-off time over, scheduling restart.
Apr 01 18:12:19 ubuntu systemd[1]: minecraft@bukkit.service: Scheduled restart job, restart counter is at 5.
It's an issue with the software screen, not screens.
Though I don't understand how it can be an issue with screen when it works OK when you start it from the CLI.

Show us the service file and how you enabled it.
 
Old 04-02-2020, 10:49 AM   #5
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Dumb question maybe. Did you accept the terms in the eula file in the server folder? If it isn't accepted it will do this. Check the server folder for eula.txt and change false to true. Then try again. I'm not sure if this applies to bukkit as I've never used it. It does for vanilla.

This is the service I use. Along with a custom script it seems to do just fine. Fair bit less complicated. I'm not sure what most of those options mean on that service. But that is my own lack of knowledge to be honest and in no way saying it is wrong.

Code:
[Unit]
Description = Launches Minecraft Servers
After = network.target ramdiskloader.service
ConditionHost = kodigst

[Service]
WorkingDirectory = /ramdisk/gameworlds/%i
Type = forking
User = mcserver
Group = mcserver
ExecStart = /usr/bin/screen -dmS %i /usr/bin/java -jar /minecraftservers/server.jar nogui
ExecStop = /usr/local/bin/mcstop %i

[Install]
WantedBy = multi-user.target
Actually after looking at yours and mine try adding

Code:
Type = forking
to the [Service] section.

That will also do it as the service just runs then dies without it.

Last edited by jmgibson1981; 04-02-2020 at 10:57 AM.
 
Old 04-02-2020, 01:54 PM   #6
TheJooomes
Member
 
Registered: May 2019
Posts: 190

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
Dumb question maybe. Did you accept the terms in the eula file in the server folder? If it isn't accepted it will do this. Check the server folder for eula.txt and change false to true. Then try again. I'm not sure if this applies to bukkit as I've never used it. It does for vanilla.

This is the service I use. Along with a custom script it seems to do just fine. Fair bit less complicated. I'm not sure what most of those options mean on that service. But that is my own lack of knowledge to be honest and in no way saying it is wrong.

Code:
[Unit]
Description = Launches Minecraft Servers
After = network.target ramdiskloader.service
ConditionHost = kodigst

[Service]
WorkingDirectory = /ramdisk/gameworlds/%i
Type = forking
User = mcserver
Group = mcserver
ExecStart = /usr/bin/screen -dmS %i /usr/bin/java -jar /minecraftservers/server.jar nogui
ExecStop = /usr/local/bin/mcstop %i

[Install]
WantedBy = multi-user.target
Actually after looking at yours and mine try adding

Code:
Type = forking
to the [Service] section.

That will also do it as the service just runs then dies without it.

I saved your script and modified it to my needs, though I hardly know a thing about bash scripting so I might of screwed up somewhere. https://pastebin.com/rjX7qGZJ

I made it executable, did systemctl start minecraft.service, got this error from journalctl -u minecraft.service. This time the server didn't even try to start. It couldn't locate java or the server directory, not sure why. In case it was a permissions thing I said heck with it and chmod ugo+rwx it, no difference.

And yes, I did accept the eula.txt, just like I would any server.
 
Old 04-02-2020, 02:42 PM   #7
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
For your exec stop that mcstop command is a script i wrote so it won't apply to you at the moment. Also remove the ConditionHost line as that is for my environment only. I'm running my servers on an LTSP pxe chroot machine, and have multiple machines running the same image but only wanted one to do the minecraft servers. As far as the rest did you install the headless java jdk? I'm not sure regular java would work as it is for gui stuff. Only a guess though.

On Ubuntu 18.04

Code:
apt install openjdk-11-jdk-headless
 
Old 04-02-2020, 04:33 PM   #8
TheJooomes
Member
 
Registered: May 2019
Posts: 190

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
For your exec stop that mcstop command is a script i wrote so it won't apply to you at the moment. Also remove the ConditionHost line as that is for my environment only. I'm running my servers on an LTSP pxe chroot machine, and have multiple machines running the same image but only wanted one to do the minecraft servers. As far as the rest did you install the headless java jdk? I'm not sure regular java would work as it is for gui stuff. Only a guess though.
I # out those 2 lines you mentioned and we made progress, we now have a new error to figure out. I also made sure that java package was installed, and it is.
Code:
root@ubuntu:~# systemctl start minecraft.service
Job for minecraft.service failed because the control process exited with error code.
See "systemctl status minecraft.service" and "journalctl -xe" for details.
systemctl status minecraft.service https://pastebin.com/TaqmY1aK
journalctl -xe https://pastebin.com/VW0Yz987

"screen[15741]: Error: Empty session-name?" seems like the main problem now, it's in both logs. That drew my attention to that "%i", what does it do/mean? I changed both instances of it to "bukkit", which is the name of the server folder, but it just threw the same screen error. I also change WorkingDirectory to /opt/minecraft/%i since I thought /opt/minecraft/bukkit/%i was wrong if "%i" represents the server folder.
 
Old 04-03-2020, 07:52 PM   #9
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Yes the %i is a variable.

Your error is back to a screen problem. If your exec start line doesn't look like mine exactly then it won't work. Empty session name means something is wrong there. The variable should be the screen session name.

Last edited by jmgibson1981; 04-03-2020 at 08:09 PM.
 
Old 04-03-2020, 09:53 PM   #10
TheJooomes
Member
 
Registered: May 2019
Posts: 190

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
Yes the %i is a variable.

Your error is back to a screen problem. If your exec start line doesn't look like mine exactly then it won't work. Empty session name means something is wrong there. The variable should be the screen session name.
Nope, the service won't even start now. Again with the No such file or directory. I did create /minecraftservers and put the jar file in it, and renamed the jar file to server.jar. I'm expecting, if it will launch, that I'll have to sign the eula.txt true, since it's in a new directory.

Code:
root@ubuntu:/minecraftservers# systemctl start minecraft.service
Job for minecraft.service failed because the control process exited with error code.
See "systemctl status minecraft.service" and "journalctl -xe" for details.


root@ubuntu:/minecraftservers# systemctl status minecraft.service
● minecraft.service - Launch Minecraft Server
   Loaded: loaded (/etc/systemd/system/minecraft.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-04-03 21:21:01 CDT; 10s ago
  Process: 1502 ExecStart=/usr/bin/screen -dmS  /usr/bin/java -jar /minecraftservers/server.jar nogui (code=exited, status=200/CHDIR)

Apr 03 21:21:01 ubuntu systemd[1]: Starting Launch Minecraft Server...
Apr 03 21:21:01 ubuntu systemd[1502]: minecraft.service: Changing to the requested working directory failed: No such file or directory
Apr 03 21:21:01 ubuntu systemd[1502]: minecraft.service: Failed at step CHDIR spawning /usr/bin/screen: No such file or directory
Apr 03 21:21:01 ubuntu systemd[1]: minecraft.service: Control process exited, code=exited status=200
Apr 03 21:21:01 ubuntu systemd[1]: minecraft.service: Failed with result 'exit-code'.
Apr 03 21:21:01 ubuntu systemd[1]: Failed to start Launch Minecraft Server.
And this is the current minecraft.service file: https://pastebin.com/kUF2pdSV

Another thing I tried was only changing the path to .jar in ExecStart while keeping everything else in that line the same as your script, I got the same error as above. Also I am making sure WorkingDirectory points to the right location each time I edit the script, with %i representing the server's directory.
 
Old 04-11-2020, 10:57 PM   #11
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Ok. I'm rewriting this post. I am sorry that I am only just now getting back to you. I have solved the issue as it hit me as well. It is due to some minor positioning errors in the script as well as a few Gotcha's! that I haven't dealt with in a few years. Here is a working service file. I ran this inside of an LXD container with 2 worlds at the same time. I suppose it would scale to as many as the hardware can handle.

Code:
[Unit]
Description = Launches Minecraft Servers
After = network.target

[Service]
WorkingDirectory = /opt/minecraft/%i
Type = forking
User = minecraft
Group = minecraft
ExecStart = /usr/bin/screen -dmS %i /usr/bin/java -jar /server.jar nogui
ExecReload = /usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "reload"\\015'
ExecStop = /usr/bin/screen -p 0 -S %i -X eval 'stuff "say SERVER SHUTDOWN IN 10 SECONDS"\\015'
ExecStop = /usr/bin/screen -p 0 -S %i -X eval 'stuff "save-all"\\015'
ExecStop = /bin/sleep 10
ExecStop = /usr/bin/screen -p 0 -S %i -X eval 'stuff "stop"\\015'

[Install]
WantedBy = multi-user.target
This is set for the variables you provided in your first post, except for the location of the .jar file. That can be wherever you wish it, make sure to use a full path. I removed the parallel threads and xmx / xms because unless you are trying to restrict, they are pointless. Minecraft will use whatever is available and no longer requires either to use everything you've got. Add back in if you need to keep minecraft from taking all available cores / memory.

I never considered putting all of that stuff into the service file other than startup. I will be modifying my own setup to use just a service file for start and stop. I'll shrink my script to just do backups and that simplifies that. Thank you for posting this issue as it helped me simplify my own setup.

The above service file requires a couple things. These are most likely the original problem.

The target world folder must exist.

Once the world is started and fails, you must agree to the eula. You also MUST change the port number for that world in server properties file. It seems the server won't let another server run if the port numbers are the same. I don't recall these issues because I already had my worlds from a long time ago along with differing port numbers. Refresher I suppose. If you plan on running more than 1 server from the same IP then I would recommend that you start with the first one and get it on a different port than default. My 3 servers are in the 50k range so I have never had this issue before, at least as I can recall.

Enjoy your minecraft server{s}. I hope it works out for you. If I'm to late, I hope this is of use to someone.

Last edited by jmgibson1981; 04-12-2020 at 12:51 AM.
 
Old 04-12-2020, 01:05 AM   #12
TheJooomes
Member
 
Registered: May 2019
Posts: 190

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
Enjoy your minecraft server{s}. I hope it works out for you.
I actually got help from someone else, this thread helped me a lot getting an understanding of systemd scripts. It turns out when we had a working script it was throwing errors because the minecraft user wasn't the owner of /opt/minecraft. I took notes of how I set it up, then used those notes to deploy the server on the real deal. Here's the file, I used my newly acquired skills to also set up a python SimpleHTTPServer script. I'm glad this thread could help, and thanks a lot for helping me learn about systemd scripts. I don't wanna change a thing in the script since the players are happy with the current setup.

PS. Don't make your root SSH password 123 and then port forward it, you'll get owned in the first 2 hours of deployment.
 
Old 07-28-2021, 07:55 AM   #13
keithmaclroz
LQ Newbie
 
Registered: Jul 2021
Posts: 1

Rep: Reputation: Disabled
Do you think there are a lot of people playing Minecraft now, or is it much less than before?
 
Old 12-02-2021, 12:14 PM   #14
COBaker
LQ Newbie
 
Registered: Feb 2021
Posts: 2

Rep: Reputation: Disabled
Yeah, I have also seen that there have been some problems with the Minecraft servers lately, but I have never experienced any of those problems while playing. I have been kicked out of a server, and no server has closed while I was playing.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Minecraft NFC -- How one man took Minecraft to the next level LXer Syndicated Linux News 0 02-21-2016 05:53 AM
[SOLVED] Launch Minecraft and Minecraft server as non-root user Hasek39 Linux - General 4 01-04-2016 03:06 AM
Minecraft world trickery (and even minecraft on ipad) lhartvik LinuxQuestions.org Member Success Stories 2 05-28-2015 01:32 AM
LXer: GOL MineCraft Weekly. Grab Issue 2 Today, Linux Minecraft server LXer Syndicated Linux News 0 08-04-2013 11:41 AM
HELP!!!!! - vncserver keeps launching in failsafe with no errors being generated dlcomm Linux - Newbie 2 12-16-2010 01:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration