mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-27 16:26:50 +01:00
chore(dev): clean up background jobs on EXIT and prop. exit code (#10916)
We were for instance calling trap at a point where it wouldn't get called, and giving special status to some processes to run in the foreground. Instead we: 1. wait for any process exit 2. use it's exit code for the calling process 3. kill background processes on EXIT
This commit is contained in:
parent
1cb2e3224a
commit
40616f0d7c
@ -3,5 +3,12 @@ set -e
|
|||||||
|
|
||||||
./bin/migrate-check
|
./bin/migrate-check
|
||||||
|
|
||||||
|
# Stop any background jobs on exit
|
||||||
|
trap 'kill $(jobs -p)' EXIT
|
||||||
|
|
||||||
./bin/plugin-server &
|
./bin/plugin-server &
|
||||||
./bin/docker-worker-celery --with-scheduler
|
./bin/docker-worker-celery --with-scheduler &
|
||||||
|
|
||||||
|
# Exit if any processes exit, and exit with it's exit code
|
||||||
|
wait -n
|
||||||
|
exit $?
|
||||||
|
@ -59,6 +59,9 @@ while test $# -gt 0; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Stop any background jobs on exit
|
||||||
|
trap 'kill $(jobs -p)' EXIT
|
||||||
|
|
||||||
if [ "$with_scheduler" == "true" ]; then
|
if [ "$with_scheduler" == "true" ]; then
|
||||||
./bin/docker-worker-beat &
|
./bin/docker-worker-beat &
|
||||||
fi
|
fi
|
||||||
@ -80,7 +83,9 @@ echo
|
|||||||
|
|
||||||
./bin/migrate-check
|
./bin/migrate-check
|
||||||
|
|
||||||
SKIP_ASYNC_MIGRATIONS_SETUP=0 celery -A posthog worker ${FLAGS[*]}
|
SKIP_ASYNC_MIGRATIONS_SETUP=0 celery -A posthog worker ${FLAGS[*]} &
|
||||||
|
|
||||||
|
# Exit if any processes exit, and exit with it's exit code
|
||||||
|
wait -n
|
||||||
|
exit $?
|
||||||
|
|
||||||
# Stop the beat!
|
|
||||||
trap 'kill $(jobs -p)' EXIT
|
|
||||||
|
@ -44,7 +44,7 @@ fi
|
|||||||
|
|
||||||
if [[ -n $NO_RESTART_LOOP ]]; then
|
if [[ -n $NO_RESTART_LOOP ]]; then
|
||||||
echo "▶️ Starting plugin server..."
|
echo "▶️ Starting plugin server..."
|
||||||
trap 'kill -TERM $child 2>/dev/null; while kill -0 $child 2>/dev/null; do sleep 1; done' SIGTERM
|
trap 'kill -TERM $child 2>/dev/null; while kill -0 $child 2>/dev/null; do sleep 1; done' EXIT
|
||||||
yarn $cmd &
|
yarn $cmd &
|
||||||
child=$!
|
child=$!
|
||||||
wait $child
|
wait $child
|
||||||
|
Loading…
Reference in New Issue
Block a user