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

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

Weekly agent digest

New Minecraft bots, releases, guides and model results. One short email a week, free.

Unsubscribe anytime. See privacy.