deploy: 添加 systemd 服务单元与配置模板(开机自启/自动重启/journald 日志)

This commit is contained in:
jocay
2026-08-27 14:25:29 +08:00
parent 29b7dc3bbb
commit 092ed48eff
3 changed files with 78 additions and 1 deletions
+24 -1
View File
@@ -103,4 +103,27 @@ python3 /tmp/bolt_http_test.py # HTTP 端到端
## 平台
- Linux / macOS(完整功能:进程组杀、信号处理)
- Windows(基础功能:`cmd /C`、`taskkill /T` 杀进程树;无信号优雅退出)
- Windows(基础功能:`cmd /C`、`taskkill /T` 杀进程树;无信号优雅退出)
## systemd 服务部署(开机自启)
仓库内 `deploy/` 提供现成的部署文件:
```bash
sudo install -m 0755 target/release/bolt /usr/local/bin/bolt
sudo cp deploy/bolt.service /etc/systemd/system/
sudo cp deploy/bolt.env.example /etc/bolt.env # 按需修改(监听地址在 service 文件 ExecStart)
sudo systemctl daemon-reload
sudo systemctl enable --now bolt # 开机自启 + 立即启动
```
常用管理命令:
```bash
systemctl status bolt # 查看状态
systemctl restart bolt # 重启(改完配置后)
systemctl stop bolt # 停止
systemctl disable bolt # 取消开机自启
journalctl -u bolt -f # 实时查看日志
```
特性:崩溃自动重启(`Restart=on-failure`,2 秒间隔)、优雅停机(SIGTERM 时杀掉所有子进程树)、日志进 journald、`LimitNOFILE=65536`。默认监听 `127.0.0.1:8080`,对外暴露前务必在 `/etc/bolt.env` 设置 `BOLT_TOKEN`。