delphi.market/hotreload.sh

37 lines
728 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
2024-07-10 04:11:28 +00:00
tailwindcss -i public/css/_tw-input.css -o public/css/tailwind.css
2024-07-10 02:48:45 +00:00
templ generate -path server/router/pages
go build -o delphi.market .
2023-09-09 20:52:50 +00:00
./delphi.market >> server.log 2>&1 &
2024-07-10 02:48:45 +00:00
templ generate -path server/router/pages
2023-09-09 20:52:50 +00:00
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