Repository navigation
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·66 lines (62 loc) · 1.58 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·66 lines (62 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -euo pipefail
cd -- "$(dirname -- "$0")"
state_dir=${HARDCI_STATE_DIR:-$PWD/state}
if [[ -f "$state_dir/harbor-intake/user-hold.json" ]]; then
printf '%s\n' 'Harbor 采集已暂停或已达成目标 (user-hold.json)。'
exit 0
fi
export HARDCI_OWNER=${HARDCI_OWNER:-$(gh config get user --host github.com 2>/dev/null || gh api user --jq .login)}
subcommands=()
if [[ "${HARDCI_DISABLE_QUOTA_SCAN:-0}" != "1" ]]; then
subcommands+=("scan --follow")
fi
subcommands+=(
"index --follow-scanned"
"intake --follow"
"review-packets --follow"
"difficulty --follow"
"semantic --follow"
"model-build --follow"
"image-build --follow"
"eval --follow"
)
if [[ "${HARDCI_ENABLE_BACKPORT:-0}" == "1" ]]; then
subcommands+=("backport --follow")
fi
children=()
stop() {
if (( ${#children[@]} )); then
kill "${children[@]}" 2>/dev/null || true
wait "${children[@]}" 2>/dev/null || true
fi
}
trap stop EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
for spec in "${subcommands[@]}"; do
read -r -a args <<< "$spec"
if command -v ionice >/dev/null 2>&1; then
ionice -c 2 -n 7 python3 -u -m cwci "${args[@]}" &
else
python3 -u -m cwci "${args[@]}" &
fi
children+=("$!")
done
while true; do
if [[ -f "$state_dir/harbor-intake/user-hold.json" ]]; then
printf '%s\n' 'Harbor 目标已达成或已暂停 (user-hold.json),正在安全停止所有子进程...'
stop
exit 0
fi
alive=0
for pid in "${children[@]}"; do
if kill -0 "$pid" 2>/dev/null; then
alive=1
break
fi
done
(( alive )) || break
sleep 10
done
wait