Files
maa-online/bin/maa-online-install-systemd
T
RRRosmontis 0264053b08 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
2026-09-19 16:45:48 +08:00

40 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install (or refresh) the systemd units that schedule the MAA Online daily
# task. Run as root. Units are rendered from systemd/*.tmpl-style sources in
# this repository with __ROOT__ replaced by the checkout path.
set -euo pipefail
ROOT="${MAA_ONLINE_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
SRC="$ROOT/systemd"
DST="${MAA_ONLINE_SYSTEMD_DIR:-/etc/systemd/system}"
UNITS=(maa-online-server.service maa-daily.service maa-daily.timer maa-update.service maa-update.timer)
if [ "$(id -u)" != "0" ]; then
echo "error: must run as root (writes to $DST)" >&2
exit 1
fi
if [ ! -d "$SRC" ]; then
echo "error: $SRC not found" >&2
exit 1
fi
for unit in "${UNITS[@]}"; do
sed "s|__ROOT__|$ROOT|g" "$SRC/$unit" > "$DST/$unit"
echo "installed $DST/$unit"
done
systemctl daemon-reload
systemctl enable --now maa-online-server.service
systemctl enable maa-daily.timer maa-update.timer
systemctl start maa-daily.timer maa-update.timer
echo
systemctl --no-pager list-timers maa-daily.timer maa-update.timer
cat <<EOF
MAA Online systemd units are active.
server log: journalctl -u maa-online-server -f
daily log: journalctl -u maa-daily -n 50
next runs: systemctl list-timers maa-daily.timer maa-update.timer
EOF