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