summaryrefslogtreecommitdiff
path: root/lib/brainstorm-server/stop-server.sh
blob: cb57d8c41c8e8b2fe31d4a7e9ec17b96bcfda22c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# Stop the brainstorm server and clean up session directory
# Usage: stop-server.sh <screen_dir>

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
  # Clean up session directory
  rm -rf "$SCREEN_DIR"
  echo '{"status": "stopped"}'
else
  echo '{"status": "not_running"}'
fi