stop-server.sh 476 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. # Stop the brainstorm server and clean up session directory
  3. # Usage: stop-server.sh <screen_dir>
  4. SCREEN_DIR="$1"
  5. if [[ -z "$SCREEN_DIR" ]]; then
  6. echo '{"error": "Usage: stop-server.sh <screen_dir>"}'
  7. exit 1
  8. fi
  9. PID_FILE="${SCREEN_DIR}/.server.pid"
  10. if [[ -f "$PID_FILE" ]]; then
  11. pid=$(cat "$PID_FILE")
  12. kill "$pid" 2>/dev/null
  13. # Clean up session directory
  14. rm -rf "$SCREEN_DIR"
  15. echo '{"status": "stopped"}'
  16. else
  17. echo '{"status": "not_running"}'
  18. fi