pterodactyl / panel

Pterodactyl® is a free, open-source game server management panel built with PHP, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
https://pterodactyl.io
Other
6.41k stars 1.57k forks source link

{{SERVER_MEMORY}} resolves to zero for unlimited ram, which prevents minecraft server from starting #2316

Closed Luro02 closed 3 years ago

Luro02 commented 3 years ago

Background (please complete the following information):

Describe the bug Setting the Allocated Memory to 0 for a server should allow unlimited memory. The Vanilla Minecraft Server Egg will be started with java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}, where the SERVER_MEMORY resolves to 0, instead of the maximum possible amount of memory for the node.

As can be seen in the console output the server fails to start:

[Pterodactyl Daemon]: Checking server disk space usage, this could take a few seconds...
[Pterodactyl Daemon]: Updating process configuration files...
[Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
container@pterodactyl~ Server marked as starting...
OpenJDK Runtime Environment (build 1.8.0_262-b10)
openjdk version "1.8.0_262"
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
:/home/container$ java -Xms128M -Xmx0M -jar serverstarter-2.0.1.jar
Error: A fatal exception has occurred. Program will exit.
Invalid maximum heap size: -Xmx0M
Error: Could not create the Java Virtual Machine.
container@pterodactyl~ Server marked as offline...
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Checking server disk space usage, this could take a few seconds...
[Pterodactyl Daemon]: Updating process configuration files...
[Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
container@pterodactyl~ Server marked as starting...
openjdk version "1.8.0_262"
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
OpenJDK Runtime Environment (build 1.8.0_262-b10)
:/home/container$ java -Xms128M -Xmx0M -jar serverstarter-2.0.1.jar
Invalid maximum heap size: -Xmx0M
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
container@pterodactyl~ Server marked as offline...
[Pterodactyl Daemon]: Aborting automatic reboot: last crash occurred less than 60 seconds ago.
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1

To Reproduce Steps to reproduce the behavior:

  1. Change a minecraft servers Allocated Memory to zero in Admin > Servers > <Server Name> > Build Configuration
  2. In the server interface under startup you can see that the startup command is
    java -Xms128M -Xmx0M -jar server.jar
  3. (Changing Allocated Memory from a specific amount to 0, did not reproduce the bug at first, but after changing the SERVER JAR FILE, it updated the cached command and the above issue occured).

Expected behavior The variable {{SERVER_MEMORY}} should resolve to the maximum allowed memory for the node instead of 0.

notAreYouScared commented 3 years ago

You should fix the title, as you're talking about {{SERVER_MEMORY}} and not {{SERVER_JARFILE}}.

This is a known issue and its unlikely to be fixed as java requires a max. In theory, you could set it to some huge value or remove the max argument for that server.

matthewpi commented 3 years ago

I've thought about this and there doesn't seem to be a good answer, Java should never be allocated more than about 8 GB of RAM unless you know what you are doing so setting the memory to the node's max memory seems like a terrible idea. Technically if you just remove the Xmx argument I believe Java will just pull more memory as it needs it until it gets killed.

Also, this is technically not a bug and more-so intended behavior.

parkervcp commented 3 years ago

My response to this is.

java -Xms128M $( [ "$SERVER_MEMORY" == "0" ] || printf %s '-Xmx{{SERVER_MEMORY}}M' ) -jar {{SERVER_JARFILE}}

When SERVER_MEMORY is 0 it won't print the -Xmx portion of the start.

Luro02 commented 3 years ago

setting the memory to the node's max memory seems like a terrible idea

Why? If you only have one server running on the node and the node is configured to only use 75% of the total ram, it would not make sense to give it any less ram.

Java should never be allocated more than about 8 GB of RAM

Especially with large modpacks (like "The 1.12 Pack") you have to allocate more than 8GB of ram, to make it run smoothly with multiple chunk loaders.

DaneEveritt commented 3 years ago

This is not a bug, it is a known limitation of the variable design and there are other open issues to extend that to support more customization.

parkervcp commented 3 years ago

I want to ask if anyone has tested my specific change that I posted last night?

ESLotherwise commented 3 years ago

I want to ask if anyone has tested my specific change that I posted last night?

Sorry for the really.. late response.

I've tested it and it works!

gekigek99 commented 3 years ago

java -Xms128M $( [ "$SERVER_MEMORY" == "0" ] || printf %s '-Xmx{{SERVER_MEMORY}}M' ) -jar {{SERVER_JARFILE}}

When SERVER_MEMORY is 0 it won't print the -Xmx portion of the start.

Shouldn't this be by default in the minecraft egg?