Skip to content

Commit e496aaa

Browse files
stubbiclaude
andcommitted
fix: use kill -9 and pkill to terminate onboard process tree
The onboard command spawns multiple child processes (pnpm, node, server) that survive a regular kill. Now uses kill -9 on the parent PID and pkill -9 to catch any remaining node processes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c47b5de commit e496aaa

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

internal/resources/statefulset.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,30 +480,33 @@ func buildOnboardInitContainer(instance *paperclipv1alpha1.Instance) corev1.Cont
480480

481481
// Create the Paperclip config file if it doesn't exist yet.
482482
// Uses `onboard --yes` which accepts quickstart defaults. Unfortunately this also
483-
// starts the server, so we run it in the background and kill it once the config exists.
483+
// starts the server, so we run it in a subshell and kill the entire process group
484+
// once the config file appears.
484485
script := `
485-
set -e
486486
CONFIG="/paperclip/instances/default/config.json"
487487
if [ -f "$CONFIG" ]; then
488488
echo "Config already exists, skipping onboard."
489489
exit 0
490490
fi
491491
echo "Running initial onboarding..."
492-
# Run onboard in background; it will start the server after creating config
493-
pnpm paperclipai onboard --yes &
492+
# Run onboard in a separate process group so we can kill the whole tree
493+
sh -c 'exec pnpm paperclipai onboard --yes' &
494494
ONBOARD_PID=$!
495-
# Wait for the config file to appear
495+
# Wait for the config file to appear (onboard creates it before starting the server)
496496
for i in $(seq 1 120); do
497497
if [ -f "$CONFIG" ]; then
498-
echo "Config created. Stopping onboard process."
499-
kill $ONBOARD_PID 2>/dev/null || true
500-
wait $ONBOARD_PID 2>/dev/null || true
498+
echo "Config created successfully."
499+
# Kill the entire process tree (onboard + server + node children)
500+
kill -9 $ONBOARD_PID 2>/dev/null || true
501+
# Also kill any remaining node processes started by onboard
502+
pkill -9 -f "paperclipai" 2>/dev/null || true
503+
pkill -9 -f "server/dist/index" 2>/dev/null || true
501504
exit 0
502505
fi
503506
sleep 1
504507
done
505508
echo "Timed out waiting for config file."
506-
kill $ONBOARD_PID 2>/dev/null || true
509+
kill -9 $ONBOARD_PID 2>/dev/null || true
507510
exit 1
508511
`
509512

0 commit comments

Comments
 (0)