delphi.market/hotreload.sh
ekzyis 7558655458 refactor: Structure code into different packages
I have put too much code into the same files.

Also, I put everything into the same package: main.

This package is only meant for executables.

Therefore, I have refactored my code to use multiple packages. These packages also guarantee separation of concerns since Golang doesn't allow cyclic imports.
2023-09-10 23:13:08 +02:00

33 lines
543 B
Bash

#!/usr/bin/env bash
PID=$(pidof delphi.market)
set -e
function restart_server() {
set +e
[[ -z "$PID" ]] || kill -15 $PID
ENV=development make build -B
set -e
./delphi.market >> server.log 2>&1 &
PID=$(pidof delphi.market)
}
function restart() {
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
done