feat: run mnote-web prod under systemd --user with auto-restart

Replace detached spawn with mnote-web-prod.service (Restart=always,
enable + Linger). prod:start installs the unit, writes env/current
symlink, and restarts via systemctl so the gateway survives kills and
logout. Also drop unused std::fs import in web_shell.
This commit is contained in:
Agent Board
2026-07-25 14:56:42 +08:00
parent 262e66b02e
commit 2deaf59f7b
3 changed files with 279 additions and 28 deletions
+30
View File
@@ -0,0 +1,30 @@
[Unit]
Description=MNote web production gateway (user)
Documentation=file:///mnt/Data1T/mnote/scripts/prod-build-start.js
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
# current 软链由 npm run prod:start 指向最新 release 目录
WorkingDirectory=/mnt/Data1T/mnote/dist/run/mnote-web-prod/current
# 生产 env 由 prod-build-start 生成(含 .env.all + bind/control-plane 覆盖)
EnvironmentFile=-/mnt/Data1T/mnote/dist/run/mnote-web-prod/env
Environment=RUST_LOG=info
ExecStart=/mnt/Data1T/mnote/dist/run/mnote-web-prod/current/mnote-web
# 崩溃/被杀后自动拉起
Restart=always
RestartSec=3
# 优雅退出窗口
TimeoutStopSec=30
KillMode=mixed
# 日志落到 journalrelease 目录内 mnote-web.log 仍可由 journalctl 旁路查看
StandardOutput=journal
StandardError=journal
SyslogIdentifier=mnote-web-prod
# 轻量资源上限,避免异常 runaway
LimitNOFILE=65536
[Install]
WantedBy=default.target