delphi.market/hotreload.sh

30 lines
534 B
Bash
Raw Normal View History

2023-09-09 20:52:50 +00:00
#!/usr/bin/env bash
PID=$(pidof delphi.market)
set -e
function restart_server() {
[[ -z "$PID" ]] || kill -15 $PID
ENV=development make build -B
./delphi.market >> server.log 2>&1 &
PID=$(pidof delphi.market)
}
function sync() {
restart_server
date +%s.%N > public/hotreload
rsync -avh public/ dev1.delphi.market:/var/www/dev1.delphi --delete
}
function cleanup() {
rm -f public/hotreload
[[ -z "$PID" ]] || kill -15 $PID
}
trap cleanup EXIT
sync
2023-09-09 20:52:50 +00:00
while inotifywait -r -e modify src/ pages/; do
2023-09-09 20:52:50 +00:00
sync
done