-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·41 lines (32 loc) · 899 Bytes
/
dev.sh
File metadata and controls
executable file
·41 lines (32 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Basic dev script, runs vite and the Go server. Rebuilds Go when a Go file changes.
set -eu
REBUILD_AFTER=3 # rebuild only after this many seconds
echo "dev: starting vite & golang; open http://localhost:8080"
# run vite
cd packages/site
./node_modules/.bin/vite --clearScreen=false &
NODE_PID=$!
cd ../../
# set dummy PID that we kill
PID=-1
function finish {
kill $NODE_PID
kill $PID
}
trap finish EXIT
# run go rebuilder
while true; do
go build -tags allow_test_dashboard_logins -o .dev ./bin/dev
./.dev -env local &
# update PID
PID=$!
echo "golang: started $PID in background"
# wait for the first .go file to change
# this is racey; files might change from when we build to now
fswatch -r -e ".*" -i "\\.go$" -1 .
echo "golang: file changed, killing $PID and restarting"
sleep $REBUILD_AFTER
kill $PID
wait $PID || echo "" # swallow err
done