feat: 增加 systemd 定时执行与断点续跑

- backend/server.py: 信令 WebSocket 被远端关闭或视频流停滞超过阈值时自动拆除会话,
  由 finally 释放网易云端实例,避免会话空挂、后续 /start 一直拿到 503
- bin/maa-online-daily-run: 新增日常任务包装脚本,等待 API 就绪、启动云游戏、
  停滞看门狗(连续 ScreencapFailed 或 Disconnected)、失败即释放云会话并最多重试 3 次
- bin/maa-resume-tasks.py: 新增断点续跑规划器,重试时只运行未出现 Completed 的任务,
  全部完成则直接判定成功,不再开启新会话;StartUp 永不跳过
- systemd/: 新增 server/daily/update 服务与定时器模板,每天 04:00 起随机 0-2 小时执行
- bin/maa-online-install-systemd: 渲染 __ROOT__ 并安装、启用上述单元
- README.md, user_config/README.md: 补充自动定时执行、断点续跑与已知限制说明
- .gitignore: 忽略生成的 config/tasks/daily-resume.toml
This commit is contained in:
RRRosmontis
2026-09-19 16:45:48 +08:00
parent 73250c91b6
commit 0264053b08
12 changed files with 481 additions and 3 deletions
+14
View File
@@ -0,0 +1,14 @@
[Unit]
Description=MAA Online daily task (Arknights via NetEase cloud game)
Requires=maa-online-server.service
After=maa-online-server.service
[Service]
Type=oneshot
ExecStart=__ROOT__/bin/maa-online-daily-run
# A normal run takes about 25 minutes; the runner's own per-attempt watchdog
# aborts a hung session well before this ceiling.
TimeoutStartSec=7200
# Safety net: whatever stops the unit (success, failure, timeout), make sure
# the remote cloud session is released.
ExecStopPost=/bin/sh -c "/usr/bin/curl --noproxy '*' -fsS -X POST http://127.0.0.1:22888/exit || true"
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Run MAA Online daily at a random moment between 04:00 and 06:00
[Timer]
OnCalendar=*-*-* 04:00:00
RandomizedDelaySec=2h
Persistent=true
Unit=maa-daily.service
[Install]
WantedBy=timers.target
+16
View File
@@ -0,0 +1,16 @@
[Unit]
Description=MAA Online cloud game API server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=__ROOT__/bin/maa-online-server
Restart=always
RestartSec=5
# Belt and braces: never let a proxy environment leak into the cloud gaming
# server (bin/maa-online-server already unsets these).
Environment=NO_PROXY=localhost,127.0.0.1,::1
[Install]
WantedBy=multi-user.target
+7
View File
@@ -0,0 +1,7 @@
[Unit]
Description=Weekly MAA Online maintenance (maa-cli, MaaCore and resource updates)
[Service]
Type=oneshot
ExecStart=__ROOT__/bin/maa-online-update
TimeoutStartSec=1800
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Weekly MAA Online maintenance, Sunday 03:20 (before the daily window)
[Timer]
OnCalendar=Sun *-*-* 03:20:00
RandomizedDelaySec=30m
Persistent=true
Unit=maa-update.service
[Install]
WantedBy=timers.target