From fa96fb3a33ffcbe914dc2f9ac82da2b47683d20c Mon Sep 17 00:00:00 2001 From: Bobby Rullo Date: Wed, 26 Aug 2015 14:23:23 -0700 Subject: [PATCH] contrib: get standup up-to-date * key_secret -> key_secrets * make sure overlord starts up before other operations since it creates the db * remove race conditions by blocking on /health being up for worker and overlord --- contrib/standup-db.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/contrib/standup-db.sh b/contrib/standup-db.sh index f5bd2175..21ee8e35 100644 --- a/contrib/standup-db.sh +++ b/contrib/standup-db.sh @@ -24,6 +24,20 @@ export DEX_WORKER_DB_URL=$DEX_DB_URL # Delete/create DB dropdb $DEX_DB; createdb $DEX_DB + +DEX_KEY_SECRET=$(dd if=/dev/random bs=1 count=32 2>/dev/null | base64) + +# Start the overlord +export DEX_OVERLORD_DB_URL=$DEX_DB_URL +export DEX_OVERLORD_KEY_SECRETS=$DEX_KEY_SECRET +export DEX_OVERLORD_KEY_PERIOD=1h +./bin/dex-overlord & +echo "Waiting for overlord to start..." +until $(curl --output /dev/null --silent --fail http://localhost:5557/health); do + printf '.' + sleep 1 +done + # Create a client eval "$(./bin/dexctl -db-url=$DEX_DB_URL new-client http://127.0.0.1:5555/callback)" @@ -49,17 +63,17 @@ EOF ./bin/dexctl -db-url=$DEX_DB_URL set-connector-configs $DEX_CONNECTORS_FILE -# Start the overlord -export DEX_OVERLORD_DB_URL=$DEX_DB_URL -export DEX_OVERLORD_KEY_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -export DEX_OVERLORD_KEY_PERIOD=1h -./bin/dex-overlord & # Start the worker export DEX_WORKER_DB_URL=$DEX_DB_URL -export DEX_WORKER_KEY_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +export DEX_WORKER_KEY_SECRETS=$DEX_KEY_SECRET export DEX_WORKER_LOG_DEBUG=1 ./bin/dex-worker & +echo "Waiting for worker to start..." +until $(curl --output /dev/null --silent --fail http://localhost:5556/health); do + printf '.' + sleep 1 +done # Start the app ./bin/example-app --client-id=$DEX_APP_CLIENT_ID --client-secret=$DEX_APP_CLIENT_SECRET --discovery=http://127.0.0.1:5556 &