跳转到内容

二进制部署

从 git 仓库的 dist/ 目录 获取对应平台的二进制——完整平台对照表见安装指南。

创建 /etc/rcommerce/config.toml:

[server]
host = "0.0.0.0"
port = 8080
[database]
db_type = "Postgres"
host = "localhost"
port = 5432
database = "rcommerce"
username = "rcommerce"
password = "your_password"
[security.jwt]
secret = "change-this-to-a-random-string"
Terminal window
rcommerce server -c /etc/rcommerce/config.toml

迁移在启动时自动执行。

创建 /etc/systemd/system/rcommerce.service:

[Unit]
Description=rCommerce API Server
After=network.target postgresql.service
[Service]
Type=simple
User=rcommerce
ExecStart=/usr/local/bin/rcommerce server -c /etc/rcommerce/config.toml
Restart=always
RestartSec=5
Environment=RUST_LOG=info
[Install]
WantedBy=multi-user.target
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable rcommerce
sudo systemctl start rcommerce

在二进制前面使用 Caddy、Nginx 或 Traefik:

api.example.com {
reverse_proxy localhost:8080
}

健康检查端点:GET /health

指标(如启用):GET /metrics(Prometheus 格式)

一个二进制可以服务任意数量的店铺——各有自己的端口、配置和 数据库。见 多店铺运维。