Skip to content

Commit a0506ee

Browse files
committed
unified process turndown
1 parent a575b98 commit a0506ee

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

examples/justfile

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,27 @@ bulletin-solo-zombienet-start runtime="bulletin-polkadot-runtime":
3939

4040
mkdir -p {{ PID_DIR }}
4141

42-
# Kill any existing zombienet process using stored PID
43-
echo "🔍 Checking for existing zombienet process..."
44-
if [ -f "{{ PID_DIR }}/zombienet.pid" ]; then
45-
ZOMBIE_PID=$(cat "{{ PID_DIR }}/zombienet.pid")
46-
if kill -0 $ZOMBIE_PID 2>/dev/null; then
47-
echo " Found existing zombienet process (PID: $ZOMBIE_PID)"
48-
echo " Killing zombienet and its child processes..."
49-
# Kill the process group to ensure all child processes are terminated
50-
pkill -9 -P $ZOMBIE_PID || true
51-
kill -9 $ZOMBIE_PID 2>/dev/null || true
52-
echo " ✓ Cleaned up zombienet process"
53-
else
54-
echo " Stale PID file found (process not running)"
55-
fi
56-
rm "{{ PID_DIR }}/zombienet.pid"
42+
# Kill any existing background processes using stored PIDs
43+
echo "🔍 Checking for existing background processes..."
44+
if [ -d "{{ PID_DIR }}" ]; then
45+
for pidfile in {{ PID_DIR }}/*.pid; do
46+
if [ -f "$pidfile" ]; then
47+
PID=$(cat "$pidfile")
48+
SERVICE=$(basename "$pidfile" .pid)
49+
if kill -0 $PID 2>/dev/null; then
50+
echo " Found existing $SERVICE process (PID: $PID)"
51+
# Kill the process and its children
52+
pkill -9 -P $PID 2>/dev/null || true
53+
kill -9 $PID 2>/dev/null || true
54+
echo " ✓ Cleaned up $SERVICE process"
55+
else
56+
echo " Stale $SERVICE PID file found (process not running)"
57+
fi
58+
rm "$pidfile"
59+
fi
60+
done
5761
else
58-
echo " No previous zombienet process found"
62+
echo " No previous processes found"
5963
fi
6064

6165
# Clean up zombienet directory to prevent "Directory already exists" prompt
@@ -287,14 +291,18 @@ teardown-services:
287291

288292
echo "🧹 Stopping all Docker services..."
289293

290-
# Stop reconnect script
294+
# Stop all background processes
291295
if [ -d {{ PID_DIR }} ]; then
292296
for pidfile in {{ PID_DIR }}/*.pid; do
293297
if [ -f "$pidfile" ]; then
294298
PID=$(cat "$pidfile")
295299
SERVICE=$(basename "$pidfile" .pid)
296-
if kill $PID 2>/dev/null; then
297-
echo " ✓ Stopped $SERVICE (PID: $PID)"
300+
if kill -0 $PID 2>/dev/null; then
301+
echo " Stopping $SERVICE (PID: $PID)..."
302+
# Kill the process and its children
303+
pkill -9 -P $PID 2>/dev/null || true
304+
kill -9 $PID 2>/dev/null || true
305+
echo " ✓ Stopped $SERVICE"
298306
else
299307
echo " ⚠ $SERVICE (PID: $PID) not running or already stopped"
300308
fi

0 commit comments

Comments
 (0)