Initialize LineUp app server
This commit is contained in:
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Minimal local supervisor for the LineUp app server. It is intentionally the
|
||||
# only process manager for this binary; the Hermes Adapter has its own script.
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
BIN="$DIR/bin/lineup-server"
|
||||
CONFIG="$DIR/configs/lineup.yaml"
|
||||
LOG="$DIR/appserver.log"
|
||||
PIDFILE="$DIR/lineup-server.pid"
|
||||
RUNTIME_ENV="$DIR/.env"
|
||||
|
||||
# Deployment secrets live beside the service, never in lineup.yaml. Viper maps
|
||||
# LINEUP_AGENT_SHARED_SECRET to agent.shared_secret automatically.
|
||||
if [[ -f "$RUNTIME_ENV" ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "$RUNTIME_ENV"
|
||||
set +a
|
||||
fi
|
||||
|
||||
is_running() {
|
||||
[[ -f "$PIDFILE" ]] && kill -0 "$(<"$PIDFILE")" 2>/dev/null
|
||||
}
|
||||
|
||||
start() {
|
||||
if is_running; then
|
||||
echo "LineUp App Server 已在运行 PID=$(<"$PIDFILE")"
|
||||
return
|
||||
fi
|
||||
cd "$DIR"
|
||||
nohup setsid "$BIN" -config "$CONFIG" >> "$LOG" 2>&1 < /dev/null &
|
||||
echo "$!" > "$PIDFILE"
|
||||
echo "LineUp App Server 已启动 PID=$(<"$PIDFILE")"
|
||||
}
|
||||
|
||||
stop() {
|
||||
if is_running; then
|
||||
kill "$(<"$PIDFILE")"
|
||||
echo "LineUp App Server 已停止"
|
||||
fi
|
||||
rm -f "$PIDFILE"
|
||||
}
|
||||
|
||||
case "${1:-start}" in
|
||||
start) start ;;
|
||||
stop) stop ;;
|
||||
restart) stop; start ;;
|
||||
status) is_running && echo "LineUp App Server 运行中 PID=$(<"$PIDFILE")" || echo "LineUp App Server 未运行" ;;
|
||||
*) echo "用法: $0 {start|stop|restart|status}"; exit 2 ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user