Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Turn ideas into validated designs and specs through collaborative dialogue before any code is written
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/stop-server.sh
1#!/usr/bin/env bash2# Stop the brainstorm server and clean up3# Usage: stop-server.sh <session_dir>4#5# Kills the server process. Only deletes session directory if it's6# under /tmp (ephemeral). Persistent directories (.superpowers/) are7# kept so mockups can be reviewed later.89SESSION_DIR="$1"1011if [[ -z "$SESSION_DIR" ]]; then12echo '{"error": "Usage: stop-server.sh <session_dir>"}'13exit 114fi1516STATE_DIR="${SESSION_DIR}/state"17PID_FILE="${STATE_DIR}/server.pid"1819if [[ -f "$PID_FILE" ]]; then20pid=$(cat "$PID_FILE")2122# Try to stop gracefully, fallback to force if still alive23kill "$pid" 2>/dev/null || true2425# Wait for graceful shutdown (up to ~2s)26for i in {1..20}; do27if ! kill -0 "$pid" 2>/dev/null; then28break29fi30sleep 0.131done3233# If still running, escalate to SIGKILL34if kill -0 "$pid" 2>/dev/null; then35kill -9 "$pid" 2>/dev/null || true3637# Give SIGKILL a moment to take effect38sleep 0.139fi4041if kill -0 "$pid" 2>/dev/null; then42echo '{"status": "failed", "error": "process still running"}'43exit 144fi4546rm -f "$PID_FILE" "${STATE_DIR}/server.log"4748# Only delete ephemeral /tmp directories49if [[ "$SESSION_DIR" == /tmp/* ]]; then50rm -rf "$SESSION_DIR"51fi5253echo '{"status": "stopped"}'54else55echo '{"status": "not_running"}'56fi57