#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" RUN_DIR="$ROOT_DIR/run" PID_FILE="$RUN_DIR/hy-app-monitor.pid" LOG_FILE="$RUN_DIR/hy-app-monitor.log" APP_BIND="${APP_BIND:-0.0.0.0}" APP_PORT="${APP_PORT:-6666}" PYTHON_BIN="${PYTHON_BIN:-python3}" TARGETS_FILE="${TARGETS_FILE:-$ROOT_DIR/config/targets.json}" mkdir -p "$RUN_DIR" read_pid() { if [ -f "$PID_FILE" ]; then cat "$PID_FILE" fi } is_running() { local pid pid="$(read_pid || true)" if [ -z "${pid:-}" ]; then return 1 fi kill -0 "$pid" >/dev/null 2>&1 }