From f09efc51d21e8350c255a0cba64551e956b32cce Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 22 Jun 2022 13:06:39 +0300 Subject: [PATCH] fix: Wait for server start in scripts/develop.sh This commit also fixes an unbound variable. --- scripts/develop.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/develop.sh b/scripts/develop.sh index 3b4cc5c0d5376..7eb7e2b3b7fc8 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -22,13 +22,15 @@ echo '== Without these binaries, workspaces will fail to start!' 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 + # Ensure the API is up before logging in. + while ! curl -s --fail localhost:3000/api/v2/ >/dev/null; do + sleep 0.5 + done - # create the first user, the admin + # 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 # || 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 + go run cmd/coder/main.go users create --email=member@coder.com --username=member --password=password || true wait )