Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #91 from FlowzPlatform/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
80017 authored Sep 26, 2018
2 parents 14dc221 + 3839f5b commit 72b8d5c
Show file tree
Hide file tree
Showing 81 changed files with 5,513 additions and 1,274 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*


# Runtime data
pids
*.pid
Expand Down Expand Up @@ -35,6 +36,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
rethinkdb_data/

# Typescript v1 declaration files
typings/
Expand All @@ -58,4 +60,4 @@ typings/
.env

service/node_modules/
client/node_modules/
client/node_modules/
63 changes: 63 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
sudo: required

language: node

services:
- docker

branches:
only:
- master
- develop
- staging
- QA

jobs:
include:
- stage: Subscription-Backend-Service-Flowz
script:
- 'if [ ${TRAVIS_BRANCH} = "master" ]; then
docker login -u="$DOCKER_USERNAME_FLOWZ" -p="$DOCKER_PASSWORD_FLOWZ";
docker build -t subscription_backend_service_flowz:latest ./service/;
docker images;
docker tag subscription_backend_service_flowz:latest $DOCKER_USERNAME_FLOWZ/subscription_backend_service_flowz:latest;
docker push $DOCKER_USERNAME_FLOWZ/subscription_backend_service_flowz:latest;
elif [ ${TRAVIS_BRANCH} = "develop" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker build -t subscription_backend_service_flowz:dev ./service/;
docker images;
docker tag subscription_backend_service_flowz:dev $DOCKER_USERNAME/subscription_backend_service_flowz:dev;
docker push $DOCKER_USERNAME/subscription_backend_service_flowz:dev;
elif [ ${TRAVIS_BRANCH} = "staging" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker build -t subscription_backend_service_flowz:$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER ./service/;
docker tag subscription_backend_service_flowz:$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER $DOCKER_USERNAME/subscription_backend_service_flowz:$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER;
docker tag subscription_backend_service_flowz:$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER $DOCKER_USERNAME/subscription_backend_service_flowz:staging;
docker images;
docker push $DOCKER_USERNAME/subscription_backend_service_flowz:$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER;
docker push $DOCKER_USERNAME/subscription_backend_service_flowz:staging;
else
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker build -t subscription_backend_service_flowz:qa ./service/;
docker images;
docker tag subscription_backend_service_flowz:qa $DOCKER_USERNAME/subscription_backend_service_flowz:qa;
docker push $DOCKER_USERNAME/subscription_backend_service_flowz:qa;
fi'
- stage: Upgrade Rancher Service
script:
- bash ./upgrade.sh
- stage: Finish Rancher Service
script:
- bash ./finish.sh

notifications:
email:
recipients:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
on_success: always
on_failure: always
41 changes: 41 additions & 0 deletions Utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
let requestPromise = require('request-promise')
let Cache = {}
const millisend = 1000
let isCachedResultValid = (result, timeout = 3600) => {
return (result && Date.now() - result.timestamp < timeout * millisend)
}

let CachedRP = (options, {key, timeout}) => {
return new Promise((resolve, reject) => {
const cachedResult = Cache[key]
// check cache key valid
if (isCachedResultValid(cachedResult, timeout)) {
// console.log('===========cachedResult return=====')
return resolve(cachedResult['result'])
}
// send request
// console.log('===========Request promise called=====')
requestPromise(options)
.then(function (resourceDetails) {
const result = resourceDetails
Cache[key] = {'result': result, 'timestamp': Date.now()}
resolve(result)
})
.catch((err) => { console.log(err); resolve(null) })
})
}

let removeTimeOutKey = (timeout = 7200) => { // TODO: only delete the old
if (Object.keys(Cache).length > 10000) {
for (let key in Object.keys(Cache)) {
if (!isCachedResultValid(Cache[key], timeout)) {
delete Cache[key]
}
}
}
}

setTimeout(removeTimeOutKey, 7200)

module.exports.isCachedResultValid = isCachedResultValid
module.exports.CachedRP = CachedRP
77 changes: 76 additions & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions client/src/components/checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ export default {
login_token: this.login_token,
payDetail: this.payDetail
}
axios({
method:'post',
url: baseUrl + "/checkout",
headers: {'authorization': auth_token},
data:sObj
}).then(res => {
console.log("response.....",res)
// console.log("response.....",res)
this.payDone = true
if (res.data.hasOwnProperty('error')) {
this.payInfo.class = 'alert alert-danger'
Expand Down
74 changes: 74 additions & 0 deletions finish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
if [ "$TRAVIS_BRANCH" = "master" ]
then
{
echo "call $TRAVIS_BRANCH branch"
ENV_ID=`curl -u ""$RANCHER_ACCESSKEY_MASTER":"$RANCHER_SECRETKEY_MASTER"" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' "$RANCHER_URL_MASTER/v2-beta/projects?name=Production" | jq '.data[].id' | tr -d '"'`
echo $ENV_ID
RANCHER_ACCESSKEY="$RANCHER_ACCESSKEY_MASTER";
RANCHER_SECRETKEY="$RANCHER_SECRETKEY_MASTER";
RANCHER_URL="$RANCHER_URL_MASTER";
SERVICE_NAME="$SERVICE_NAME_MASTER";
}
elif [ "$TRAVIS_BRANCH" = "develop" ]
then
{
echo "call $TRAVIS_BRANCH branch"
ENV_ID=`curl -u ""$RANCHER_ACCESSKEY_DEVELOP":"$RANCHER_SECRETKEY_DEVELOP"" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' "$RANCHER_URL_DEVELOP/v2-beta/projects?name=Develop" | jq '.data[].id' | tr -d '"'`
echo $ENV_ID
RANCHER_ACCESSKEY="$RANCHER_ACCESSKEY_DEVELOP";
RANCHER_SECRETKEY="$RANCHER_SECRETKEY_DEVELOP";
RANCHER_URL="$RANCHER_URL_DEVELOP";
SERVICE_NAME="$SERVICE_NAME_DEVELOP";
}
elif [ "$TRAVIS_BRANCH" = "staging" ]
then
{
echo "call $TRAVIS_BRANCH branch"
ENV_ID=`curl -u ""$RANCHER_ACCESSKEY_STAGING":"$RANCHER_SECRETKEY_STAGING"" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' "$RANCHER_URL_STAGING/v2-beta/projects?name=Staging" | jq '.data[].id' | tr -d '"'`
echo $ENV_ID
RANCHER_ACCESSKEY="$RANCHER_ACCESSKEY_STAGING";
RANCHER_SECRETKEY="$RANCHER_SECRETKEY_STAGING";
RANCHER_URL="$RANCHER_URL_STAGING";
SERVICE_NAME="$SERVICE_NAME_STAGING";
}
else
{
echo "call $TRAVIS_BRANCH branch"
ENV_ID=`curl -u ""$RANCHER_ACCESSKEY_QA":"$RANCHER_SECRETKEY_QA"" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' "$RANCHER_URL_QA/v2-beta/projects?name=Develop" | jq '.data[].id' | tr -d '"'`
echo $ENV_ID
RANCHER_ACCESSKEY="$RANCHER_ACCESSKEY_QA";
RANCHER_SECRETKEY="$RANCHER_SECRETKEY_QA";
RANCHER_URL="$RANCHER_URL_QA";
SERVICE_NAME="$SERVICE_NAME_QA";

}
fi

SERVICE_ID=`curl -u ""$RANCHER_ACCESSKEY":"$RANCHER_SECRETKEY"" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' "$RANCHER_URL/v2-beta/projects/$ENV_ID/services?name=$SERVICE_NAME" | jq '.data[].id' | tr -d '"'`
echo $SERVICE_ID

echo "waiting for service to upgrade "
while true; do

case `curl -u ""$RANCHER_ACCESSKEY":"$RANCHER_SECRETKEY"" \
-X GET \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
"$RANCHER_URL/v2-beta/projects/$ENV_ID/services/$SERVICE_ID/" | jq '.state'` in
"\"upgraded\"" )
echo "completing service upgrade"
curl -u ""$RANCHER_ACCESSKEY":"$RANCHER_SECRETKEY"" \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
"$RANCHER_URL/v2-beta/projects/$ENV_ID/services/$SERVICE_ID?action=finishupgrade"
break ;;
"\"upgrading\"" )
echo "still upgrading"
echo -n "."
sleep 60
continue ;;
*)
die "unexpected upgrade state" ;;
esac
done
Loading

0 comments on commit 72b8d5c

Please sign in to comment.