From 7c6a41b5f14038e7eec27086f56ed4c27bc594ab Mon Sep 17 00:00:00 2001 From: Cameron Crothers Date: Thu, 1 Oct 2015 09:17:46 +1000 Subject: [PATCH 1/3] Check for existence of ROOT_URL in the same way as MONGO_URL --- bin/release | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/release b/bin/release index 2520fc2..17f33e1 100755 --- a/bin/release +++ b/bin/release @@ -17,10 +17,12 @@ extract_mongo_url() { } extract_root_url() { - #echo "Pulling ROOT_URL from VCAP_APPLICATION" - DOMAIN=`echo $VCAP_APPLICATION | $jq '.uris[0]' | sed -e 's/^"//' -e 's/"$//'` - export ROOT_URL="http://$DOMAIN" - #echo "ROOT_URL: $ROOT_URL" + if [ -z "${ROOT_URL}" ]; then + #echo "Pulling ROOT_URL from VCAP_APPLICATION" + DOMAIN=`echo $VCAP_APPLICATION | $jq '.uris[0]' | sed -e 's/^"//' -e 's/"$//'` + export ROOT_URL="http://$DOMAIN" + #echo "ROOT_URL: $ROOT_URL" + fi } extract_mongo_url From d6fa1f3346bbd9b335de5a9c60eafe81dcb4f360 Mon Sep 17 00:00:00 2001 From: Ash Austin Date: Thu, 1 Oct 2015 16:03:25 +1000 Subject: [PATCH 2/3] Added logic to extract COUCHDB_URL from VCAP_SERVICES --- bin/release | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/release b/bin/release index 17f33e1..3d024af 100755 --- a/bin/release +++ b/bin/release @@ -25,8 +25,17 @@ extract_root_url() { fi } +extract_couchdb_url() { + if [ -z "${COUCHDB_URL}" ]; then + #echo "Pulling COUCHDB_URL from VCAP_SERVICES" + # Find the first service key that contains "cloudant", then grab the 'url' (or 'uri') key beneath it. + export COUCHDB_URL=`echo $VCAP_SERVICES | $jq 'to_entries|map(select(.key|contains("cloudant")))[0]|.value[0].credentials|if .url then .url else .uri end|. // empty'` + fi +} + extract_mongo_url extract_root_url +extract_couchdb_url cat <<-YAML --- From 7b9948e472eb87d933a0fb1fec747eaf2e52fa3a Mon Sep 17 00:00:00 2001 From: Ash Austin Date: Thu, 1 Oct 2015 16:30:37 +1000 Subject: [PATCH 3/3] Forgot to put the variable in the latest git push! n00b. --- bin/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/release b/bin/release index 3d024af..94d8511 100755 --- a/bin/release +++ b/bin/release @@ -40,5 +40,5 @@ extract_couchdb_url cat <<-YAML --- default_process_types: - web: MONGO_URL=$MONGO_URL ROOT_URL=$ROOT_URL vendor/node/bin/node deploy/bundle/main.js + web: MONGO_URL=$MONGO_URL COUCHDB_URL=$COUCHDB_URL ROOT_URL=$ROOT_URL vendor/node/bin/node deploy/bundle/main.js YAML