feat: add prefixed service initializer and packaged deployment

This commit is contained in:
shiran
2026-09-09 11:00:31 +08:00
parent 1e2366998e
commit 4da89b784e
9 changed files with 355 additions and 40 deletions
+9 -2
View File
@@ -1,7 +1,14 @@
#!/bin/bash
SERVICES="server cli scheduler"
set -euo pipefail
for svc in $SERVICES; do
APP_DIR="$(cd "$(dirname "$0")" && pwd)"
PREFIX_FILE="$APP_DIR/.service-prefix"
[ -f "$PREFIX_FILE" ] || { echo "缺少 $PREFIX_FILE,请先运行 initializer"; exit 1; }
SERVICE_PREFIX="$(tr -d '\r\n' < "$PREFIX_FILE")"
[[ "$SERVICE_PREFIX" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]] || { echo "无效的服务前缀: $SERVICE_PREFIX"; exit 1; }
SERVICES=("${SERVICE_PREFIX}-server" "${SERVICE_PREFIX}-cli" "${SERVICE_PREFIX}-scheduler")
for svc in "${SERVICES[@]}"; do
if systemctl is-active --quiet "$svc"; then
systemctl stop "$svc"
echo "[$svc] 已停止"