Skip to content

Commit

Permalink
fix: restart once
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Oct 11, 2024
1 parent b6279e5 commit 6249dde
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions scripts/restart-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ handle_int() {
trap handle_term SIGTERM
trap handle_int SIGINT

while [ "$killed" -eq 0 ]; # stop looping if we were interrupted
do
# start change script and our server
echo 'starting process...'
"$@" &
child=$!
sleep 10 && echo "killing pid $child..." && kill -9 "$child"
while kill -0 "$child" 2> /dev/null; do # wait for child to exit (kill -0 is falsy if pid is gone)
sleep 1
done
echo 'killed process...' && sleep 5
# start change script and our server
echo 'starting process...'
"$@" &
child=$!
sleep 10
echo "killing pid $child..."
kill -9 "$child"
while kill -0 "$child" 2> /dev/null; do # wait for child to exit (kill -0 is falsy if pid is gone)
sleep 1
done
echo 'killed...'
sleep 5
echo 'restarting process...'
"$@"

0 comments on commit 6249dde

Please sign in to comment.