Run Minecraft Neoforge server as daemon

I have been running a vanilla minecraft server for some time, and wanted to add a mod instance. I have setup a jail for this, and within the jail, vanilla minecraft server is working in daemon mode fine. The specific mods require 1.21.1 and Forge/Neoforge. I was able to "downgrade" from 1.21.11 to 1.21.1 by stopping the server, downloading the 1.21.1 server.jar file and putting it in the /usr/local/minecraft-server, then restarting the service.

I downloaded the appropriate Neoforge version, and ran its installer. It placed a run.sh file in the server folder, and I can run that and have the server running with all the appropriate mods. For my purposes, I want this running in daemon mode instead, and this is where I am stuck. I'm sure I can figure it out, but right now the only time I can work on this is at the end of the day when my mental power has been completely drained. Anyone have experience running a Forge or Neoforge server instance as a daemon that can point me in the right direction?

If I figure it out first, I'll reply back here with the instructions for anyone else who may want to know. FWIW, my server is running FreeBSD 14.4, but I don't think that makes any difference in the configuration.
 
You'll have to look at the run.sh to see what it's doing. Is it online somewhere?

A quick and dirty hack would be to just run it inside tmux(1).
 
The games/minecraft-server port includes a proper rc(8) script, take that as an example. Modify it a bit so it starts your minecraft server including the mods. That'll get you something you can use to automatically start the game server, and be able to start/stop it with the service(8) command.
 
Neoforge's run.sh is one line:
Code:
java @user_jvm_args.txt @libraries/net/neoforged/neoforge/21.1.228/unix_args.txt "$@"

usr_jvm_args.txt is currently empty, but the example is to use this to set memory allocation. The unix_args.txt has a significant amount of arguments in it.
checking the rc script, the minecraft_args option seems relevant. The default is empty, but I imagine what is in the unix_args.txt would need to be applied here. Could I use a file in an rc script to feed the arguments?
 
I run minecraft servers using some simple wrapper scripts and using screen to access the detached console. I haven't tried any rc scripts that ship in ports. You'll likely need to adjust things because forge servers load a different jar file than the server.jar.
 
Back
Top