Files
maa-online/bin/maa-online-install-systemd
T
RRRosmontis 636ecbd974 feat: 增加内存观测日志
- bin/maa-online-memlog: 每分钟采集一次服务 cgroup 匿名内存、swap 占用、进程 RSS、
  以及大于 32 MB 的匿名映射数量(glibc arena 膨胀指纹),追加写入 logs/memlog.csv,
  超过 5 MB 自动滚动并保留一代;同时输出一行到 journald
- systemd/maa-online-memlog.service, maa-online-memlog.timer: 每分钟触发采集,
  Nice=10 避免影响流媒体负载
- bin/maa-online-install-systemd: 安装并启用观测定时器,安装提示补充内存日志路径
- README.md, user_config/README.md: 补充内存观测说明、字段表与查看命令
- .gitignore: 忽略运行期产生的 logs/
2026-09-20 13:07:19 +08:00

41 lines
1.5 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 maa-online-recycle.service maa-online-recycle.timer maa-online-memlog.service maa-online-memlog.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 maa-online-recycle.timer maa-online-memlog.timer
systemctl start maa-daily.timer maa-update.timer maa-online-recycle.timer maa-online-memlog.timer
echo
systemctl --no-pager list-timers maa-daily.timer maa-update.timer maa-online-recycle.timer maa-online-memlog.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
memory log: tail -f $ROOT/logs/memlog.csv
next runs: systemctl list-timers 'maa-*'
EOF