diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index ae98c7e87..8ec4cfc48 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -1,18 +1,25 @@ #!/bin/bash -echo "Before getopt" -for i -do - echo $i -done -args=`getopt b:p: $*` -set -- $args -echo "After getopt" -for i -do - echo "-->$i" +while [ "$#" -gt 0 ]; do + case "$1" in + -a) ARG_API="${2:-1_0}"; shift 2;; + -b) ARG_BRANCH="${2:-master}"; shift 2;; + + --api-version=*) ARG_API="${1#*=}"; shift 1;; + --branch=*) ARG_BRANCH="${1#*=}"; shift 1;; + --api-version|--branch) echo "$1 requires an argument" >&2; exit 1;; + + -*) echo "unknown option: $1" >&2; exit 1;; + *) handle_argument "$1"; shift 1;; + esac done +echo "==================================================" +echo "Arguments:" +echo " -api-version = $ARG_API" +echo " -branch = $ARG_BRANCH" +echo "==================================================" + # Find current directory & configure paths set -o allexport SCRIPT_PATH=$(realpath $0) @@ -76,7 +83,8 @@ echo 'Stopping all Gradido services' >> $UPDATE_HTML pm2 stop all # git -BRANCH=${1:-master} +# BRANCH=${1:-master} +BRANCH=$ARG_BRANCH echo "Starting with git pull - branch:$BRANCH" >> $UPDATE_HTML cd $PROJECT_ROOT # TODO: this overfetches alot, but ensures we can use start.sh with tags @@ -177,6 +185,13 @@ yarn build # TODO maybe handle this differently? export NODE_ENV=production pm2 delete gradido-federation +# set FEDERATION_PORT from ARG_API +port=${ARG_API//_/} +FEDERATION_PORT=$(($FEDERATION_PORT + $port)) +export FEDERATION_PORT +echo "====================================================" +echo " start federation listening on port=$FEDERATION_PORT +echo "====================================================" pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' pm2 save diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index c8a841315..82011a6bc 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -73,7 +73,7 @@ if ( const federation = { // FEDERATION_DHT_TOPIC: process.env.FEDERATION_DHT_TOPIC || null, // FEDERATION_DHT_SEED: process.env.FEDERATION_DHT_SEED || null, - FEDERATION_PORT: process.env.FEDERATION_PORT || 5010, + FEDERATION_PORT: process.env.FEDERATION_PORT || 5000, FEDERATION_API: process.env.FEDERATION_API || '1_0', FEDERATION_COMMUNITY_URL: process.env.FEDERATION_COMMUNITY_URL || null, }