PayrollManagementSystem/docker/tplus-maintenance.sh

24 lines
611 B
Bash
Raw Normal View History

#!/bin/sh
# 复用已有单次检查命令;即使检查失败也保留日志并等待下一轮。
set -u
stopping=0
child_pid=
stop() {
stopping=1
if [ -n "$child_pid" ]; then
kill -TERM "$child_pid" 2>/dev/null || :
fi
}
trap stop TERM INT
while [ "$stopping" -eq 0 ]; do
python -m app.cli tplus-maintain --once &
child_pid=$!
if ! wait "$child_pid" && [ "$stopping" -eq 0 ]; then
echo 'T+ 周期检查未完成,请检查运行配置;下一轮重试。' >&2
fi
[ "$stopping" -eq 0 ] || break
sleep 60 &
child_pid=$!
wait "$child_pid" || :
done