Systemd 服务
创建 /etc/systemd/system/rcommerce.service:
[Unit]Description=rCommerce API ServerAfter=network.target postgresql.service
[Service]Type=simpleUser=rcommerceGroup=rcommerceExecStart=/usr/local/bin/rcommerce server -c /etc/rcommerce/config.tomlRestart=alwaysRestartSec=5Environment=RUST_LOG=infoEnvironment=STOREFRONT_URL=https://your-store.com
[Install]WantedBy=multi-user.target# 创建用户sudo useradd -r -s /bin/false rcommerce
# 设置权限sudo chown rcommerce:rcommerce /usr/local/bin/rcommercesudo chown -R rcommerce:rcommerce /etc/rcommerce
# 启用并启动sudo systemctl daemon-reloadsudo systemctl enable rcommercesudo systemctl start rcommerce
# 查看状态sudo systemctl status rcommerce# 实时日志sudo journalctl -u rcommerce -f
# 最近 100 行sudo journalctl -u rcommerce -n 100sudo systemctl restart rcommerce在 [Service] 段中设置:
RUST_LOG—— 日志级别STOREFRONT_URL—— 邮件链接中的店面 URLRCOMMERCE_CONFIG—— 配置文件路径(-c参数的替代方式)