mirror of https://github.com/coder/coder.git
improve develop.sh (#2572)
- Running make dev now prompts you to run ./scripts/develop.sh manually, as GNU make does not appear to pass SIGINT to subprocesses. - Added checks to develop.sh to ensure that coderd is listening before running our initial setup steps - Add some more troubleshooting/debugging output to develop.sh
This commit is contained in:
parent
7f778316ac
commit
dc7d6def8e
3
Makefile
3
Makefile
|
@ -60,8 +60,9 @@ coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
|
|||
coderd/database/querier.go: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
|
||||
coderd/database/generate.sh
|
||||
|
||||
# This target is deprecated, as GNU make has issues passing signals to subprocesses.
|
||||
dev:
|
||||
./scripts/develop.sh
|
||||
@echo Please run ./scripts/develop.sh manually.
|
||||
.PHONY: dev
|
||||
|
||||
fmt/prettier:
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Allow toggling verbose output
|
||||
[[ -n ${VERBOSE:-""} ]] && set -x
|
||||
set -euo pipefail
|
||||
set -x
|
||||
|
||||
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
# shellcheck disable=SC1091
|
||||
source "${SCRIPT_DIR}/lib.sh"
|
||||
PROJECT_ROOT=$(cd "$SCRIPT_DIR" && git rev-parse --show-toplevel)
|
||||
set +u
|
||||
CODER_DEV_ADMIN_PASSWORD="${CODER_DEV_ADMIN_PASSWORD:-password}"
|
||||
set -u
|
||||
|
||||
# Preflight checks: ensure we have our required dependencies, and make sure nothing is listening on port 3000 or 8080
|
||||
dependencies curl git go make nc yarn
|
||||
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
|
||||
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
|
||||
|
||||
echo '== Run "make build" before running this command to build binaries.'
|
||||
echo '== Without these binaries, workspaces will fail to start!'
|
||||
|
@ -16,19 +27,20 @@ echo '== Without these binaries, workspaces will fail to start!'
|
|||
# to kill both at the same time. For more details, see:
|
||||
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
|
||||
(
|
||||
SCRIPT_PID=$$
|
||||
cd "${PROJECT_ROOT}"
|
||||
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -${SCRIPT_PID} &
|
||||
go run -tags embed cmd/coder/main.go server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -${SCRIPT_PID} &
|
||||
|
||||
trap 'kill 0' SIGINT
|
||||
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev &
|
||||
go run -tags embed cmd/coder/main.go server --in-memory --tunnel &
|
||||
|
||||
# Just a minor sleep to ensure the first user was created to make the member.
|
||||
sleep 2
|
||||
echo '== Waiting for Coder to become ready'
|
||||
timeout 60s bash -c 'until curl -s --fail http://localhost:3000 > /dev/null 2>&1; do sleep 0.5; done'
|
||||
|
||||
# create the first user, the admin
|
||||
go run cmd/coder/main.go login http://127.0.0.1:3000 --username=admin --email=admin@coder.com --password=password || true
|
||||
go run cmd/coder/main.go login http://127.0.0.1:3000 --username=admin --email=admin@coder.com --password="${CODER_DEV_ADMIN_PASSWORD}" ||
|
||||
echo 'Failed to create admin user. To troubleshoot, try running this command manually.'
|
||||
|
||||
# || yes to always exit code 0. If this fails, whelp.
|
||||
go run cmd/coder/main.go users create --email=member@coder.com --username=member --password="${CODER_DEV_ADMIN_PASSWORD}" || true
|
||||
# || true to always exit code 0. If this fails, whelp.
|
||||
go run cmd/coder/main.go users create --email=member@coder.com --username=member --password="${CODER_DEV_ADMIN_PASSWORD}" ||
|
||||
echo 'Failed to create regular user. To troubleshoot, try running this command manually.'
|
||||
wait
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue