Crash Recovery
PocketMC supervises running server processes, protects against crash loops, automates maintenance reboots with in-game warnings, and prevents Windows from entering sleep mode while servers are active.
Crash Loop Protection
When a server terminates unexpectedly due to an unhandled exception or memory error, PocketMC captures the exit code and crash report:
- Exponential backoff: PocketMC attempts up to 3 automated restarts with progressive delays (10s, 30s, 60s).
- Failure halt: If the server fails to complete its boot sequence within 3 consecutive attempts, PocketMC suspends further restarts, flags the instance in an error state, and logs the stack trace.
- Health reset: Once a server stays online and operational past the initial startup window, the failure counter resets to zero.
Child Process Supervision (Job Objects)
Traditional batch scripts can leave orphaned Java processes running in the background when the terminal window closes. PocketMC binds each launched server process to a Windows Job Object:
- Kernel-level tracking: Uses
CreateJobObjectandAssignProcessToJobObjectfrom Windowskernel32.dll. - Kill on close: Configured with
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE(0x2000). If PocketMC is closed, terminates, or crashes, the Windows kernel terminates all child Java, Bedrock, and tunnel processes automatically. - Port release: Prevents orphaned JVMs from holding port leases or locking save files.
Scheduled Reboots & In-Game Broadcasts
Long-running Minecraft servers can experience memory fragmentation over days of continuous operation.
PocketMC's ServerRebootSchedulerService manages scheduled restarts:
Reboot Modes
Configure reboot behavior per instance under Instance SettingsMaintenance & Recovery:
- Daily window: Restarts your server at a fixed local time each day (for example,
04:00 AM). PocketMC tracks day boundaries to prevent duplicate restarts within the same window. - Uptime interval: Restarts the server after a set number of operational hours (such as every 12 or 24 hours).
- Startup safeguard: The scheduler ignores restart triggers if the server was booted less than 60 seconds ago, preventing restart loops during boot.
In-Game Countdown Alerts
When countdown warnings are enabled:
- PocketMC initiates a countdown before restarting (default: 60 seconds).
- Sends countdown alerts to in-game chat using
sayat staged intervals (60s, 30s, 15s, 10s, 5s down to 1s). - Broadcasts a final message (
Server is rebooting now...) immediately before issuing the shutdown command. - If an administrator manually stops the instance during a countdown, the scheduled task cancels immediately.
Windows Sleep Inhibition
Windows power settings normally put idle desktop computers to sleep, which drops active player connections.
PocketMC includes a sleep prevention service that calls SetThreadExecutionState with ES_SYSTEM_REQUIRED | ES_CONTINUOUS while any server runs.
A coordinator tracks running instances; when the last server stops, normal Windows power-saving behavior resumes automatically.