AstrBot Service Setup

posted
read
61 words · 1 min
contents

This note records a minimal AstrBot deployment on a VPS.

Example values:

  • service user: astrbot
  • working directory: /opt/astrbot
  • local port: 6185
  • public domain: bot.example.com
  • bot token: example-bot-token-please-change
  • callback path: /callback/astrbot

Replace all example secrets before using the config.

Install uv

Terminal window
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version

Install AstrBot

Terminal window
uv tool install astrbot
command -v astrbot
astrbot --help

If astrbot is installed under the service user’s home directory, use the absolute path in the systemd unit.

Environment File

Terminal window
sudo install -d -m 0750 -o astrbot -g astrbot /opt/astrbot
sudo vim /opt/astrbot/.env

Example .env:

BOT_TOKEN=example-bot-token-please-change
CALLBACK_URL=https://bot.example.com/callback/astrbot
ADMIN_ID=10000001
PORT=6185

systemd Unit

[Unit]
Description=AstrBot Service
After=network.target
[Service]
Type=simple
User=astrbot
Group=astrbot
WorkingDirectory=/opt/astrbot
EnvironmentFile=/opt/astrbot/.env
ExecStart=/home/astrbot/.local/bin/astrbot
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target

Enable it:

Terminal window
sudo systemctl daemon-reload
sudo systemctl enable --now astrbot
sudo systemctl status astrbot

Reverse Proxy

bot.example.com {
reverse_proxy 127.0.0.1:6185
}

Logs

Terminal window
journalctl -u astrbot -e --no-pager
journalctl -u astrbot -f