start.sh is the process that actually runs inside the tmux session. Its
primary job is to run the Minecraft server and automatically restart it if it
crashes — unless the shutdown was intentional.
You do not normally invoke
start.sh directly. Use serv start instead,
which sets up the tmux session, exports the necessary environment variables,
and runs start.sh inside it.How the loop works
The script registers aSIGINT/SIGTERM signal trap and runs in a while loop that continues as long as a keep_running flag is true. Each iteration of the loop:
- Checks for a
stop_signalfile before launching. If found, setskeep_running=falseand removes the file — server does not start. - Launches the Java process and blocks until it exits.
- Checks for
stop_signalagain immediately after the process exits. - If
keep_runningis stilltrue, waits 5 seconds, checksstop_signalone final time, then restarts.
The stop_signal file
Thestop_signal file is the mechanism that differentiates an intentional stop from a crash. The script also traps SIGINT and SIGTERM — pressing Ctrl+C inside the tmux session sets keep_running=false without needing the file.
This means a crash at any time — including during a snapshot window — will
trigger an automatic restart within 5 seconds, unless
serv stop was called
first.
JVM flags
The server is launched with the following JVM arguments:
The jar is launched with the
nogui flag, which disables the Swing GUI that
would otherwise fail in a headless environment.
tmux session details
The socket is created with permissions
770 after the session is started, so
users in the owning group can attach without root.
Graceful stop vs crash
Graceful stop viaserv stop:
java command and the server comes back up
automatically. The tmux session and the loop itself remain alive throughout,
so serv console continues to work even between restarts.