Skip to content

Deployment

deploy/deploy.sh installs the framework on a fresh Ubuntu VPS in one run: code, Python venv, Lavalink, and systemd units for both services.

Running deploy.sh

bash deploy/deploy.sh root@your-vps [remote_dir] [lavalink_dir]
  • remote_dir defaults to /opt/rootbot, lavalink_dir to /opt/lavalink.

  • The SSH command defaults to plain ssh; override it when the box needs a key, port, or jump route:

    ROOTBOT_SSH="ssh -i ~/.ssh/mykey" bash deploy/deploy.sh root@your-vps

What it does, in order:

  1. Ships the code as a tar stream over SSH. Excluded: .venv, __pycache__, .env, config.json, serve.log, .git, your local secrets never travel.

  2. Installs system packages that are missing: python3 (+ venv), ffmpeg, curl, and OpenJDK 17 headless for Lavalink.

  3. Builds the venv and installs requirements.txt (livekit==1.3.0, yt-dlp).

  4. Seeds config from templates if absent: .env (mode 600) and examples/musicbot/config.json. Existing files are never overwritten.

  5. Sets up Lavalink: downloads the 4.2.2 jar if missing, installs the application.yml template if missing, and warns if the youtube-source plugin jar is not in plugins/ (it must be built from source, see Lavalink).

  6. Installs the systemd units, rewriting the /opt/rootbot and /opt/lavalink paths to your chosen directories, and enables both.

  7. Starts Lavalink, unless port 2333 is already in use by a non-systemd process, in which case it leaves that process alone and the unit takes over once it stops.

  8. Starts the bot, only if .env already existed with a token. On a first deploy it stops and tells you to fill in ROOT_TOKEN first:

    systemctl start rootbot-musicbot

The systemd units

Both units live in deploy/systemd/ and are installed to /etc/systemd/system/.

rootbot-musicbot.service, runs the bot:

  • WorkingDirectory=<remote_dir>, EnvironmentFile=<remote_dir>/.env
  • ExecStart=<remote_dir>/.venv/bin/python -m examples.musicbot.musicbot serve
  • After=network-online.target lavalink.service, Restart=on-failure (5 s backoff)
  • stdout/stderr append to <remote_dir>/serve.log

lavalink.service, runs the sidecar:

  • WorkingDirectory=<lavalink_dir>
  • ExecStart=/usr/bin/java -jar <lavalink_dir>/Lavalink.jar
  • Restart=on-failure (5 s backoff)
  • stdout/stderr append to <lavalink_dir>/lavalink.log

Running without systemd

bash examples/musicbot/serve.sh          # bot, foreground, loads .env
bash deploy/lavalink/start-lavalink.sh   # Lavalink via nohup

One-off checks without the serve loop (run from the repo root with the venv active and .env loaded):

python -m examples.musicbot.musicbot          # SessionCreate + join test
python -m examples.musicbot.musicbot tone     # join and play a 10 s tone
python -m examples.musicbot.musicbot play <url>  # join and play one track

Logs

LogContents
<remote_dir>/serve.logBot startup line (discovery=api … primed N messages), watched containers, every command received, poll/presence errors, join/leave events.
<lavalink_dir>/lavalink.logLavalink startup, plugin load, OAuth device code and token-refresh lines, stream errors.
journalctl -u rootbot-musicbot -u lavalinkUnit lifecycle (starts, crashes, restarts).

Updating

Re-run deploy.sh with the same arguments. It re-ships the code and rebuilds the venv, preserves the remote .env and config.json (they are excluded from the tar and the template-seeding never overwrites), re-installs the units, and restarts the bot.

Rollback

There is no automated rollback, deploy overwrites the remote directory in place. If an update matters, snapshot first:

ssh root@your-vps "cp -a /opt/rootbot /opt/rootbot.bak-$(date +%F)"

To roll back: stop rootbot-musicbot, move the backup directory back into place, systemctl daemon-reload (in case units changed), and start the service again.

Docker (compose)

The repository root carries a Dockerfile and compose.yml for the same deployment, for hosts where containers are preferred over systemd:

cp config.example.json config.json   # fill in your community/container ids
mkdir -p data && cp config.json data/config.json
cat > .env <<'ENV'
ROOT_TOKEN=<the bot account's token>
LAVALINK_PASSWORD=<a password you choose>
ENV
docker compose up -d --build

The constraints are part of the design, not defaults to relax:

  • Local build only. The bot image builds from the Dockerfile; nothing is pushed to a registry.
  • No default Lavalink password. Compose refuses to start unless ROOT_TOKEN and LAVALINK_PASSWORD are set in the environment or the .env file; the same password value is handed to Lavalink and to the bot.
  • Lavalink is not published. It has no host ports; only the bot container can reach it, on the compose network. Its http and local sources are disabled, and the youtube-source plugin jar goes in the lavalink-plugins volume (see the Lavalink guide for building it).
  • Health is a heartbeat file. The bot's wrapper touches /app/data/heartbeat while the bot process lives; the healthcheck fails once the file goes stale.
  • Settings live on the rootbot-data volume (config.json, the framework settings file), never in the image.