5
5
6
6
SCRIPT_DIR=$( dirname " ${BASH_SOURCE[0]} " )
7
7
PROJECT_ROOT=$( cd " $SCRIPT_DIR " && git rev-parse --show-toplevel)
8
+ set +u
9
+ CODER_DEV_ADMIN_PASSWORD=" ${CODER_DEV_ADMIN_PASSWORD:- password} "
10
+ set -u
11
+
12
+ # Preflight check: make sure nothing is listening on port 3000 or 8080
13
+ nc -z 127.0.0.1 3000 && echo ' == ERROR: something is listening on port 3000. Kill it and re-run this script.' && exit 1
14
+ nc -z 127.0.0.1 8080 && echo ' == ERROR: something is listening on port 8080. Kill it and re-run this script.' && exit 1
8
15
9
16
echo ' == Run "make build" before running this command to build binaries.'
10
17
echo ' == Without these binaries, workspaces will fail to start!'
@@ -17,18 +24,19 @@ echo '== Without these binaries, workspaces will fail to start!'
17
24
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
18
25
(
19
26
cd " ${PROJECT_ROOT} "
20
-
21
- trap ' kill 0' SIGINT
27
+ # Send an interrupt signal to all processes in this subshell on exit
22
28
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev &
23
29
go run -tags embed cmd/coder/main.go server --in-memory --tunnel &
24
30
25
- # Just a minor sleep to ensure the first user was created to make the member.
26
- sleep 2
31
+ echo ' == Waiting for Coder to become ready '
32
+ timeout 60s bash -c ' until nc -z 127.0.0.1 3000 > /dev/null 2>&1; do sleep 1; done '
27
33
28
34
# create the first user, the admin
29
- go run cmd/coder/main.go login http://127.0.0.1:3000 --username=admin --email=admin@coder.com --password=password || true
35
+ go run cmd/coder/main.go login http://127.0.0.1:3000 --username=admin --email=admin@coder.com --password=password \
36
+ || echo ' Failed to create admin user. To troubleshoot, try running this command manually.'
30
37
31
- # || yes to always exit code 0. If this fails, whelp.
32
- go run cmd/coder/main.go users create --email=member@coder.com --username=member --password=" ${CODER_DEV_ADMIN_PASSWORD} " || true
38
+ # || true to always exit code 0. If this fails, whelp.
39
+ go run cmd/coder/main.go users create --email=member@coder.com --username=member --password=" ${CODER_DEV_ADMIN_PASSWORD} " \
40
+ || echo ' Failed to create regular user. To troubleshoot, try running this command manually.'
33
41
wait
34
42
)
0 commit comments