AstrBot Service Setup
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
1 2
| curl -LsSf https://astral.sh/uv/install.sh | sh uv --version
|
Install AstrBot
1 2 3
| 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
1 2
| sudo install -d -m 0750 -o astrbot -g astrbot /opt/astrbot sudo vim /opt/astrbot/.env
|
Example .env:
1 2 3 4
| BOT_TOKEN=example-bot-token-please-change CALLBACK_URL=https://bot.example.com/callback/astrbot ADMIN_ID=10000001 PORT=6185
|
systemd Unit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| [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:
1 2 3
| sudo systemctl daemon-reload sudo systemctl enable --now astrbot sudo systemctl status astrbot
|
Reverse Proxy
1 2 3
| bot.example.com { reverse_proxy 127.0.0.1:6185 }
|
Logs
1 2
| journalctl -u astrbot -e --no-pager journalctl -u astrbot -f
|