Host a bot 24/7 cheaply
This is the pattern behind Steve: one small Linux VPS, the bot as a systemd service, and hard memory limits.
1. Cap Node's memory
Node's --max-old-space-size flag sets the V8 old-generation heap limit in MiB, so a leak crashes and restarts the bot instead of the whole box:
node --max-old-space-size=1024 bot.js
2. Run it as a systemd service
Create /etc/systemd/system/mcbot.service:
[Unit] Description=Minecraft bot After=network-online.target Wants=network-online.target [Service] User=mcbot WorkingDirectory=/home/mcbot/bot ExecStart=/usr/bin/node --max-old-space-size=1024 bot.js Restart=always RestartSec=10 [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable --now mcbot journalctl -u mcbot -f # live logs
Restart=always restarts the process whenever it exits; RestartSec sets the delay.
3. Add watchdogs in code
- Memory watchdog: check
process.memoryUsage().rssand exit cleanly below the cap (Steve uses ~850 MB on a 1 GB heap); systemd brings it back - Idle watchdog: if the bot has made no progress for N minutes, exit and restart
- Reconnect on
end/kickedevents, with backoff
4. Server on the same box?
A small Paper server and a bot can share one budget VPS for a handful of players. Keep RCON bound to localhost only and never put credentials in your repo.
Prefer managed hosting for the server? Apex Hosting (affiliate).
Sources: systemd.service docs · Node.js CLI docs · Node process.memoryUsage · Paper docs