github.com/grahambrereton-form3/tilt@v0.10.18/integration/onewatch/start.sh (about) 1 #!/bin/sh 2 # 3 # A helper script to implement restart_container when the docker runtime isn't available. 4 # 5 # Usage: 6 # Copy start.sh and restart.sh to your container working dir. 7 # 8 # Make your container entrypoint: 9 # ./start.sh path-to-binary [args] 10 # 11 # To restart the container: 12 # ./restart.sh 13 14 set -euo pipefail 15 16 process_id="" 17 18 trap quit TERM INT 19 20 quit() { 21 if [ -n "$process_id" ]; then 22 kill $process_id 23 fi 24 } 25 26 while true; do 27 rm -f restart.txt 28 29 "$@" & 30 process_id=$! 31 echo "$process_id" > process.txt 32 set +e 33 wait $process_id 34 EXIT_CODE=$? 35 set -e 36 if [ ! -f restart.txt ]; then 37 exit $EXIT_CODE 38 fi 39 echo "Restarting" 40 done