mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-14 05:30:55 +00:00
Route mock alert cleanup through managed runtime
This commit is contained in:
parent
ec99ef6018
commit
9b9ee97f85
3 changed files with 142 additions and 5 deletions
|
|
@ -9,7 +9,9 @@ GREEN='\033[0;32m'
|
|||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
ALERT_HISTORY="/etc/pulse/alerts/alert-history.json"
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
HOT_DEV_BG_PATH="${HOT_DEV_BG_PATH:-${ROOT_DIR}/scripts/hot-dev-bg.sh}"
|
||||
ALERT_HISTORY="${ALERT_HISTORY:-/etc/pulse/alerts/alert-history.json}"
|
||||
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo -e "${RED}Error: jq is required but not installed${NC}"
|
||||
|
|
@ -33,6 +35,16 @@ run_privileged() {
|
|||
fi
|
||||
}
|
||||
|
||||
managed_runtime_running() {
|
||||
if [ ! -x "$HOT_DEV_BG_PATH" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local status_output
|
||||
status_output="$("$HOT_DEV_BG_PATH" status 2>/dev/null || true)"
|
||||
[[ "$status_output" == *"[hot-dev-bg] Running (pid:"* ]]
|
||||
}
|
||||
|
||||
if [ ! -f "$ALERT_HISTORY" ]; then
|
||||
echo -e "${RED}Error: Alert history file not found at $ALERT_HISTORY${NC}"
|
||||
exit 1
|
||||
|
|
@ -57,7 +69,12 @@ echo -e "${GREEN}✓ Backup created: $BACKUP_FILE${NC}"
|
|||
|
||||
# Stop backend to prevent writes during cleanup
|
||||
echo "Stopping backend..."
|
||||
if managed_runtime_running; then
|
||||
echo "Stopping managed development runtime..."
|
||||
"$HOT_DEV_BG_PATH" stop
|
||||
fi
|
||||
pkill -x pulse 2>/dev/null || true
|
||||
# Legacy compatibility for service-based deployments that are not using the managed dev runtime.
|
||||
run_privileged systemctl stop pulse-hot-dev 2>/dev/null || true
|
||||
run_privileged systemctl stop pulse 2>/dev/null || true
|
||||
run_privileged systemctl stop pulse-backend 2>/dev/null || true
|
||||
|
|
@ -84,7 +101,7 @@ run_privileged chown pulse:pulse "$ALERT_HISTORY"
|
|||
echo -e "${GREEN}✓ Mock alerts removed successfully${NC}"
|
||||
echo ""
|
||||
echo "To restart the backend, run:"
|
||||
echo " npm run dev (managed development runtime)"
|
||||
echo " ./scripts/hot-dev.sh (foreground development escape hatch)"
|
||||
echo " sudo systemctl start pulse (systemd)"
|
||||
echo " sudo systemctl start pulse-backend (legacy)"
|
||||
echo " (cd \"${ROOT_DIR}\" && npm run dev) (managed development runtime)"
|
||||
echo " (cd \"${ROOT_DIR}\" && npm run dev:foreground) (foreground development escape hatch)"
|
||||
echo " sudo systemctl start pulse (systemd)"
|
||||
echo " sudo systemctl start pulse-backend (legacy)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue