资源卡依赖关系及类型分类预览 (#129)
完成资源卡按类型和按依赖分类展现的功能 Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/129 Co-authored-by: menghao <mh18530625731@163.com> Co-committed-by: menghao <mh18530625731@163.com>
This commit was merged in pull request #129.
This commit is contained in:
@@ -6,6 +6,36 @@ MAINTENANCE_FILE="${GENARRATIVE_MAINTENANCE_FILE:-/var/lib/genarrative/maintenan
|
||||
MAINTENANCE_PAGE_FILE="${GENARRATIVE_MAINTENANCE_PAGE_FILE:-/var/lib/genarrative/maintenance/page.html}"
|
||||
PAGE_SOURCE=""
|
||||
REASON_PARTS=()
|
||||
page_temp=""
|
||||
marker_temp=""
|
||||
|
||||
cleanup_temps() {
|
||||
if [[ -n "${page_temp}" ]]; then
|
||||
rm -f -- "${page_temp}"
|
||||
fi
|
||||
if [[ -n "${marker_temp}" ]]; then
|
||||
rm -f -- "${marker_temp}"
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup_temps EXIT
|
||||
|
||||
replace_file_atomically() {
|
||||
local source_file="$1"
|
||||
local target_file="$2"
|
||||
|
||||
if [[ -L "${target_file}" ]]; then
|
||||
echo "[maintenance] 原子替换目标不能是符号链接: ${target_file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -d "${target_file}" ]]; then
|
||||
echo "[maintenance] 原子替换目标不能是目录: ${target_file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
# 源文件与目标文件位于同一目录,POSIX rename 语义即可保证原子替换。
|
||||
# 不使用 GNU mv 专属的 -T,确保 macOS/BSD 本地门禁也能执行。
|
||||
mv -f "${source_file}" "${target_file}"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
@@ -39,9 +69,8 @@ mkdir -p "$(dirname "${MAINTENANCE_FILE}")" "$(dirname "${MAINTENANCE_PAGE_FILE}
|
||||
|
||||
if [[ -n "${PAGE_SOURCE}" ]]; then
|
||||
page_temp="$(mktemp "${MAINTENANCE_PAGE_FILE}.tmp.XXXXXX")"
|
||||
trap 'rm -f "${page_temp:-}" "${marker_temp:-}"' EXIT
|
||||
install -m 0644 -- "${PAGE_SOURCE}" "${page_temp}"
|
||||
mv -fT -- "${page_temp}" "${MAINTENANCE_PAGE_FILE}"
|
||||
replace_file_atomically "${page_temp}" "${MAINTENANCE_PAGE_FILE}"
|
||||
page_temp=""
|
||||
echo "[maintenance] 已安装本次运行态公告页: ${MAINTENANCE_PAGE_FILE}"
|
||||
elif [[ ! -f "${MAINTENANCE_FILE}" && ( -e "${MAINTENANCE_PAGE_FILE}" || -L "${MAINTENANCE_PAGE_FILE}" ) ]]; then
|
||||
@@ -55,7 +84,7 @@ marker_temp="$(mktemp "${MAINTENANCE_FILE}.tmp.XXXXXX")"
|
||||
} >"${marker_temp}"
|
||||
|
||||
chmod 0644 "${marker_temp}"
|
||||
mv -fT -- "${marker_temp}" "${MAINTENANCE_FILE}"
|
||||
replace_file_atomically "${marker_temp}" "${MAINTENANCE_FILE}"
|
||||
marker_temp=""
|
||||
trap - EXIT
|
||||
echo "[maintenance] 已进入维护模式: ${MAINTENANCE_FILE}"
|
||||
|
||||
@@ -892,7 +892,9 @@ ensure_default_worker_service() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
mapfile -t services < <(list_worker_services "${pattern}")
|
||||
while IFS= read -r service; do
|
||||
services+=("${service}")
|
||||
done < <(list_worker_services "${pattern}")
|
||||
if [[ "${#services[@]}" -gt 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
@@ -1033,7 +1035,9 @@ restart_worker_services() {
|
||||
fi
|
||||
|
||||
ensure_default_worker_service "${pattern}"
|
||||
mapfile -t services < <(list_worker_services "${pattern}")
|
||||
while IFS= read -r service; do
|
||||
services+=("${service}")
|
||||
done < <(list_worker_services "${pattern}")
|
||||
if [[ "${#services[@]}" -eq 0 ]]; then
|
||||
echo "[production-api-deploy] 未发现已加载的外部生成 worker 单元: ${pattern}" >&2
|
||||
return 1
|
||||
@@ -1052,7 +1056,9 @@ wait_for_worker_services() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
mapfile -t services < <(list_worker_services "${pattern}")
|
||||
while IFS= read -r service; do
|
||||
services+=("${service}")
|
||||
done < <(list_worker_services "${pattern}")
|
||||
if [[ "${#services[@]}" -eq 0 ]]; then
|
||||
echo "[production-api-deploy] 外部生成 worker 单元不存在,发布失败: ${pattern}" >&2
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user