Skip to content

Commit 94074c0

Browse files
committed
Merge branch 'main' into wslogs
2 parents 58e060f + dc7d6de commit 94074c0

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
6060
coderd/database/querier.go: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
6161
coderd/database/generate.sh
6262

63+
# This target is deprecated, as GNU make has issues passing signals to subprocesses.
6364
dev:
64-
./scripts/develop.sh
65+
@echo Please run ./scripts/develop.sh manually.
6566
.PHONY: dev
6667

6768
fmt/prettier:

scripts/develop.sh

+22-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
#!/usr/bin/env bash
22

3+
# Allow toggling verbose output
4+
[[ -n ${VERBOSE:-""} ]] && set -x
35
set -euo pipefail
4-
set -x
56

67
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
8+
# shellcheck disable=SC1091
9+
source "${SCRIPT_DIR}/lib.sh"
710
PROJECT_ROOT=$(cd "$SCRIPT_DIR" && git rev-parse --show-toplevel)
11+
set +u
12+
CODER_DEV_ADMIN_PASSWORD="${CODER_DEV_ADMIN_PASSWORD:-password}"
13+
set -u
14+
15+
# Preflight checks: ensure we have our required dependencies, and make sure nothing is listening on port 3000 or 8080
16+
dependencies curl git go make nc yarn
17+
nc -z 127.0.0.1 3000 >/dev/null 2>&1 && echo '== ERROR: something is listening on port 3000. Kill it and re-run this script.' && exit 1
18+
nc -z 127.0.0.1 8080 >/dev/null 2>&1 && echo '== ERROR: something is listening on port 8080. Kill it and re-run this script.' && exit 1
819

920
echo '== Run "make build" before running this command to build binaries.'
1021
echo '== Without these binaries, workspaces will fail to start!'
@@ -16,19 +27,20 @@ echo '== Without these binaries, workspaces will fail to start!'
1627
# to kill both at the same time. For more details, see:
1728
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
1829
(
30+
SCRIPT_PID=$$
1931
cd "${PROJECT_ROOT}"
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 --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -${SCRIPT_PID} &
2034

21-
trap 'kill 0' SIGINT
22-
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev &
23-
go run -tags embed cmd/coder/main.go server --in-memory --tunnel &
24-
25-
# Just a minor sleep to ensure the first user was created to make the member.
26-
sleep 5
35+
echo '== Waiting for Coder to become ready'
36+
timeout 60s bash -c 'until curl -s --fail http://localhost:3000 > /dev/null 2>&1; do sleep 0.5; done'
2737

2838
# 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
39+
go run cmd/coder/main.go login http://127.0.0.1:3000 --username=admin --email=admin@coder.com --password="${CODER_DEV_ADMIN_PASSWORD}" ||
40+
echo 'Failed to create admin user. To troubleshoot, try running this command manually.'
3041

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=password || true
42+
# || true to always exit code 0. If this fails, whelp.
43+
go run cmd/coder/main.go users create --email=member@coder.com --username=member --password="${CODER_DEV_ADMIN_PASSWORD}" ||
44+
echo 'Failed to create regular user. To troubleshoot, try running this command manually.'
3345
wait
3446
)

0 commit comments

Comments
 (0)