diff options
Diffstat (limited to 'lib/brainstorm-server/stop-server.sh')
| -rwxr-xr-x | lib/brainstorm-server/stop-server.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/brainstorm-server/stop-server.sh b/lib/brainstorm-server/stop-server.sh new file mode 100755 index 0000000..c3724de --- /dev/null +++ b/lib/brainstorm-server/stop-server.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Stop the brainstorm server and clean up +# Usage: stop-server.sh <screen_dir> +# +# Kills the server process. Only deletes session directory if it's +# under /tmp (ephemeral). Persistent directories (.superpowers/) are +# kept so mockups can be reviewed later. + +SCREEN_DIR="$1" + +if [[ -z "$SCREEN_DIR" ]]; then + echo '{"error": "Usage: stop-server.sh <screen_dir>"}' + exit 1 +fi + +PID_FILE="${SCREEN_DIR}/.server.pid" + +if [[ -f "$PID_FILE" ]]; then + pid=$(cat "$PID_FILE") + kill "$pid" 2>/dev/null + rm -f "$PID_FILE" "${SCREEN_DIR}/.server.log" + + # Only delete ephemeral /tmp directories + if [[ "$SCREEN_DIR" == /tmp/* ]]; then + rm -rf "$SCREEN_DIR" + fi + + echo '{"status": "stopped"}' +else + echo '{"status": "not_running"}' +fi |
