#!/bin/sh python -m http.server 3000 --directory build & PID_HTTP=$! sleep 2 if ! kill -0 $PID_HTTP 2>/dev/null; then echo "Failed to start HTTP server" exit 1 fi # When using the -d flag, entr will exist, so just keep looping with a function to get it to relaunch watch_static() { while true; do echo resources/static/ | entr -dp rsync -av --delete resources/static/ build/static/ sleep 0.5 done } watch_static & PID_WATCH_STATIC=$! cleanup() { echo "Shutting down..." kill $PID_HTTP 2>/dev/null kill $PID_WATCH_STATIC 2>/dev/null exit 0 } trap cleanup SIGINT SIGTERM find src/ resources/ -name "*.clj" -o -name "*.edn" | entr -r clj -M:build cleanup