Skip to content

Hosting

arielaram edited this page Nov 16, 2026 · 1 revision

Hosting

How to keep the bot online, restart it after a crash or reboot, back it up and update it.

What to host

  • The bot needs outbound internet only (to Discord). No port has to be open for the bot itself.
  • The admin panel (3000) and the API (2222) are for you. Open them to the internet only through HTTPS, see Nginx Guide or Ngrok Guide.
  • Never expose port 2222 raw. Its write routes need a token, but it should still stay behind a proxy with HTTPS.

Pick a machine

Option Good for Watch out for
Home PC or mini PC Testing and small servers Power cuts, sleep settings, Windows updates restarts
Linux VPS Always-on hosting Choose a region near your players, keep the OS updated
Raspberry Pi 4/5 (ARM64) Cheap always-on SD cards wear out: keep backups
Old Android phone with Termux Experiments See the section below

Run it as a service (Linux, systemd)

Create /etc/systemd/system/nationdex.service (replace the user and paths):

[Unit]
Description=Nationdex 2026 bot
After=network-online.target
Wants=network-online.target

[Service]
User=nationdex
WorkingDirectory=/home/nationdex/nationdex
ExecStart=/home/nationdex/nationdex/nationdex-bot-linux-x64
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Then:

sudo systemctl daemon-reload
sudo systemctl enable --now nationdex
sudo systemctl status nationdex
journalctl -u nationdex -f        # live log

WorkingDirectory matters: the bot reads .env and assets/ from the folder it starts in, and creates database/ there.

Run it as a service (Windows)

Easiest: run the .exe from a terminal inside its folder and keep the PC awake. For a real service, use a tool such as NSSM (https://nssm.cc) and set the service folder to the bot's folder. Untested by the maintainers.

Backups

The whole state is the database/ folder. Copy it while the bot is stopped, so the copy is consistent.

sudo systemctl stop nationdex
tar -czf ~/backups/database-$(date +%F).tar.gz -C /home/nationdex/nationdex database
sudo systemctl start nationdex

Keep copies off the machine as well. Also keep a copy of .env, stored safely (it holds the token).

Restoring: stop the bot, move the database/ folder aside, extract the backup into the same place, start the bot. Never run two copies against the same database/ folder.

Updating

  1. Download the new release and SHA256SUMS.txt, check the hash.
  2. Stop the bot, back up database/ first.
  3. Replace the program file. Keep .env, database/ and assets/. Check the release notes for asset changes.
  4. Start the bot and watch the log.

Keep the old program file until the new one has run fine.

Keeping it alive on a phone

  • Plug the phone in and keep it on a charger that does not overheat.
  • Turn off battery optimisation for Termux in Android settings.
  • Use tmux (see Termux guide) so closing the window does not stop the bot.
  • Expect restarts after Android updates. Restart by hand if the bot is offline.

Checking that it is up

curl http://localhost:2222/v1/stats

A JSON answer means the bot and API are up. Players should also see the bot online in Discord.

Clone this wiki locally