Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52b2589

Browse files
committed
add suggestion from mafredri
1 parent c1c4404 commit 52b2589

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

scripts/develop.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
set -euo pipefail
66

77
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
8+
# shellcheck disable=SC1091
89
source "${SCRIPT_DIR}/lib.sh"
910
PROJECT_ROOT=$(cd "$SCRIPT_DIR" && git rev-parse --show-toplevel)
1011
set +u
1112
CODER_DEV_ADMIN_PASSWORD="${CODER_DEV_ADMIN_PASSWORD:-password}"
1213
set -u
1314

1415
# 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
1819

1920
echo '== Run "make build" before running this command to build binaries.'
2021
echo '== Without these binaries, workspaces will fail to start!'
@@ -26,20 +27,20 @@ echo '== Without these binaries, workspaces will fail to start!'
2627
# to kill both at the same time. For more details, see:
2728
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
2829
(
30+
SCRIPT_PID=$$
2931
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} &
3334

3435
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'
3637

3738
# 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.'
4041

4142
# || 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.'
4445
wait
4546
)

0 commit comments

Comments
 (0)