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_dirdefaults to/opt/rootbot,lavalink_dirto/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:
Ships the code as a tar stream over SSH. Excluded:
.venv,__pycache__,.env,config.json,serve.log,.git, your local secrets never travel.Installs system packages that are missing:
python3(+ venv),ffmpeg,curl, and OpenJDK 17 headless for Lavalink.Builds the venv and installs
requirements.txt(livekit==1.3.0,yt-dlp).Seeds config from templates if absent:
.env(mode600) andexamples/musicbot/config.json. Existing files are never overwritten.Sets up Lavalink: downloads the 4.2.2 jar if missing, installs the
application.ymltemplate if missing, and warns if the youtube-source plugin jar is not inplugins/(it must be built from source, see Lavalink).Installs the systemd units, rewriting the
/opt/rootbotand/opt/lavalinkpaths to your chosen directories, and enables both.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.
Starts the bot, only if
.envalready existed with a token. On a first deploy it stops and tells you to fill inROOT_TOKENfirst: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>/.envExecStart=<remote_dir>/.venv/bin/python -m examples.musicbot.musicbot serveAfter=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.jarRestart=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 nohupOne-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 trackLogs
| Log | Contents |
|---|---|
<remote_dir>/serve.log | Bot startup line (discovery=api … primed N messages), watched containers, every command received, poll/presence errors, join/leave events. |
<lavalink_dir>/lavalink.log | Lavalink startup, plugin load, OAuth device code and token-refresh lines, stream errors. |
journalctl -u rootbot-musicbot -u lavalink | Unit 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 --buildThe 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_TOKENandLAVALINK_PASSWORDare set in the environment or the.envfile; 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
httpandlocalsources are disabled, and the youtube-source plugin jar goes in thelavalink-pluginsvolume (see the Lavalink guide for building it). - Health is a heartbeat file. The bot's wrapper touches
/app/data/heartbeatwhile the bot process lives; the healthcheck fails once the file goes stale. - Settings live on the
rootbot-datavolume (config.json, the framework settings file), never in the image.