-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·37 lines (27 loc) · 987 Bytes
/
Copy pathstop.sh
File metadata and controls
executable file
·37 lines (27 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -e
# GitHub Self-Hosted Runner Stop Script
# Gracefully stops and removes all GitHub runner containers
echo "Stopping GitHub runners..."
echo ""
# Get list of running runner containers
RUNNER_CONTAINERS=$(docker ps --filter "name=github-runner-" --format "{{.Names}}" | sort)
if [ -z "$RUNNER_CONTAINERS" ]; then
echo "No running GitHub runner containers found."
exit 0
fi
CONTAINER_COUNT=$(echo "$RUNNER_CONTAINERS" | wc -l | tr -d ' ')
echo "Found $CONTAINER_COUNT runner container(s)"
echo ""
# Stop each runner gracefully
for CONTAINER_NAME in $RUNNER_CONTAINERS; do
echo "Stopping $CONTAINER_NAME..."
# Try graceful shutdown first (runner will unregister itself via start.sh cleanup)
docker stop -t 30 "$CONTAINER_NAME" > /dev/null 2>&1 || true
# Remove the container
docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true
echo " $CONTAINER_NAME stopped and removed"
done
echo ""
echo "All GitHub runners stopped successfully!"
exit 0