You are not logged in.

#1 2012-12-19 15:52:26

beretta
Member
Registered: 2008-04-21
Posts: 133

[Solved] Second Minecraft Server

I want to host two minecraft servers on my machine. I've been able to get it to work by setting up a separate directory and running the .jar file directly with:

java -Xmx2G -Xms1G -jar /srv/minecraft2/minecraft_server.jar

When I run directly, it brings up a window in X with the server status and log, as opposed to running in screen like the standard server from minecraft-server-systemd does. That's alright, but I will be away for a while for the holiday, and would like to be able to start/stop the server at will remotely. What would be ideal would be to set up a second daemon for the server that behaves just like the one installed.

I've tried copying how it's done in minecraft-server-systemd, but unfortunately it encounters an error, only visible when running directly rather than in screen:

 > sudo su minecraft -c "java -Xmx2G -Xms1G -jar /srv/minecraft2/minecraft_server.jar"

208 recipes
27 achievements
No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
	at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
	at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
	at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:186)
	at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
	at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
	at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:119)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:186)
	at java.awt.Toolkit$2.run(Toolkit.java:870)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:862)
	at javax.swing.UIManager.getSystemLookAndFeelClassName(UIManager.java:608)
	at hv.a(SourceFile:24)
	at ho.an(SourceFile:328)
	at net.minecraft.server.MinecraftServer.main(SourceFile:838)

Actually, this error occurs with the original server too, and this command only seems to work when I start the minecraftd daemon in systemd. I tried copying minecraftd.service to mcserver2d.service, changing the file accordingly (using mcserver2 instead of minecraft for the screen name), but it doesn't work. No error is displayed, but when trying to connect minecraft searches for the server for a while and gives up.

Does anyone else run two servers on their machine? How have you done it? Anyone familiar enough with the minecraft-server-systemd install there that can give me some tips to what I might be doing wrong?

Last edited by beretta (2012-12-21 16:18:40)

Offline

#2 2012-12-19 17:04:24

PReP
Member
From: Sweden
Registered: 2010-06-13
Posts: 359
Website

Re: [Solved] Second Minecraft Server

I do not know why it seems to "need" X11 for starting the server.

Have you tried manually starting each minecraft-instance with tmux (or screen) with different names,
and then you just log in to the server with ssh, and re-attach the session you need to work on in turn?

That's how i'd go about it as a first attempt, though i only run one mc-server on my machine.


. Main: Intel Core i5 6600k @ 4.4 Ghz, 16 GB DDR4 XMP, Gefore GTX 970 (Gainward Phantom) - Arch Linux 64-Bit
. Server: Intel Core i5 2500k @ 3.9 Ghz, 8 GB DDR2-XMP RAM @ 1600 Mhz, Geforce GTX 570 (Gainward Phantom) - Arch Linux 64-Bit
. Body: Estrogen @ 90%, Testestorone @ 10% (Not scientific just out-of-my-guesstimate-brain)

Offline

#3 2012-12-19 20:59:05

beretta
Member
Registered: 2008-04-21
Posts: 133

Re: [Solved] Second Minecraft Server

Yes, that's essentially what I tried. Running the command without screen shows the error I'm getting; with screen, I get nothing.

 > sudo screen -dmS minecraft2 su minecraft -c "java -Xms1G -Xmx2G -jar /srv/minecraft2/minecraft_server.jar"

 > sudo screen -r minecraft2
There is no screen to be resumed matching minecraft2.

 > 

This structure matches the command in /usr/bin/minecraftd, with the memory allocations doubled. (Using the default memory doesn't work either, of course.)

I've also tried running the command in /usr/bin/minecraftd explicitly (using the original server). Same behavior; I can only get it to work by running the .jar manually (which opens the window in X), or by using systemctl start minecraftd.

Offline

#4 2012-12-20 16:49:27

chungy
Member
Registered: 2009-09-07
Posts: 32

Re: [Solved] Second Minecraft Server

You need to pass "nogui" as a parameter to the Java program.  So: java -Xms1G -Xmx2G -jar /srv/minecraft2/minecraft_server.jar nogui

With the nogui parameter, it even works fine with only jre7-openjdk-headless or similar, so no X11 components need to be installed on the system.

Offline

#5 2012-12-21 16:18:07

beretta
Member
Registered: 2008-04-21
Posts: 133

Re: [Solved] Second Minecraft Server

Thanks; that's close enough to the functionality I was looking for.

Offline

Board footer

Powered by FluxBB