OverviewFilesCommitsIssuesDocsReleasesPeers

pear-git-v3 / scripts / legacy / pgv3-stop.sh

32 lines · bash ref:
#!/bin/bash
# Stop pear-git-v3 daemon in tmux. Sends C-c, waits for graceful exit,
# then kills the window.

set -e

SESSION="pear-seed"
WINDOW="pear-git-v3"

if ! tmux list-windows -t "$SESSION" 2>/dev/null | grep -q "^[0-9]*: $WINDOW\\b"; then
  echo "No pgv3 window in $SESSION session" >&2
  exit 1
fi

echo "Stopping pgv3..."
tmux send-keys -t "$SESSION:$WINDOW" C-c

# Give the daemon up to ~5s to exit gracefully so corestore flushes
for i in 1 2 3 4 5; do
  sleep 1
  # If the process isn't holding the socket anymore, we can proceed
  if [ ! -S /home/fleeky/pgv3-storage/svc.sock ] 2>/dev/null; then
    break
  fi
done

tmux kill-window -t "$SESSION:$WINDOW"

echo "pgv3 stopped"
echo "To restart:"
echo "  \$(dirname \$0)/pgv3-start.sh"