github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/integration/ignores/start.sh (about) 1 #!/bin/sh 2 # 3 # A helper script to restart a given process as part of a Live Update. 4 # 5 # Further reading: 6 # https://docs.tilt.dev/live_update_reference.html#restarting-your-process 7 # 8 # Usage: 9 # Copy start.sh and restart.sh to your container working dir. 10 # 11 # Make your container entrypoint: 12 # ./start.sh path-to-binary [args] 13 # 14 # To restart the container: 15 # ./restart.sh 16 17 set -eu 18 19 process_id="" 20 21 trap quit TERM INT 22 23 quit() { 24 if [ -n "$process_id" ]; then 25 kill $process_id 26 fi 27 } 28 29 while true; do 30 rm -f restart.txt 31 32 "$@" & 33 process_id=$! 34 echo "$process_id" > process.txt 35 set +e 36 wait $process_id 37 EXIT_CODE=$? 38 set -e 39 if [ ! -f restart.txt ]; then 40 echo "Exiting with code $EXIT_CODE" 41 exit $EXIT_CODE 42 fi 43 echo "Restarting" 44 done