delphi.market/hotreload.sh

33 lines
543 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() {
2023-09-09 20:52:51 +00:00
set +e
2023-09-09 20:52:50 +00:00
[[ -z "$PID" ]] || kill -15 $PID
ENV=development make build -B
2023-09-09 20:52:51 +00:00
set -e
2023-09-09 20:52:50 +00:00
./delphi.market >> server.log 2>&1 &
PID=$(pidof delphi.market)
}
function restart() {
2023-09-09 20:52:50 +00:00
restart_server
date +%s.%N > public/hotreload
}
function cleanup() {
rm -f public/hotreload
[[ -z "$PID" ]] || kill -15 $PID
}
trap cleanup EXIT
restart
tail -f server.log &
while inotifywait -r -e modify db/ env/ lib/ lnd/ pages/ public/ server/; do
restart
2023-09-09 20:52:50 +00:00
done