Skip to content

Commit a575b98

Browse files
committed
store PID in /tmp
1 parent d7a1ae0 commit a575b98

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

examples/justfile

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

4040
mkdir -p {{ PID_DIR }}
4141

42-
# Kill any existing zombienet processes to prevent conflicts
43-
echo "🔍 Checking for existing zombienet processes..."
44-
ZOMBIE_PIDS=$(pgrep -f "zombienet.*spawn" || true)
45-
if [ -n "$ZOMBIE_PIDS" ]; then
46-
echo " Found existing zombienet processes: $ZOMBIE_PIDS"
47-
echo " Killing existing zombienet processes..."
48-
pkill -9 -f "zombienet.*spawn" || true
49-
# Also kill any polkadot/polkadot-parachain processes from previous runs
50-
pkill -9 -f "polkadot.*--chain.*bulletin" || true
51-
pkill -9 -f "polkadot-parachain.*--chain.*bulletin" || true
52-
pkill -9 -f "polkadot-bulletin-chain" || true
53-
echo " ✓ Cleaned up existing processes"
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"
57+
else
58+
echo " No previous zombienet process found"
5459
fi
5560

56-
# Clean up stale PID file
57-
[ -f "{{ PID_DIR }}/zombienet.pid" ] && rm "{{ PID_DIR }}/zombienet.pid"
58-
5961
# Clean up zombienet directory to prevent "Directory already exists" prompt
6062
if [ -d "{{ ZOMBIENET_DIR }}" ]; then
6163
echo " Cleaning up existing zombienet directory: {{ ZOMBIENET_DIR }}"

0 commit comments

Comments
 (0)