arg

Home   »   arg

#!/bin/bash
export REPOROOT=`pwd`
MICROSERVICES=()
while (( "$#" )); do
  case "$1" in
    -a|--all)
      MICROSERVICES=("client" "comments" "event-bus" "moderation" "posts" "query")
      shift
      ;;
    -c|--comments)
        MICROSERVICES=("comments")
        shift
      ;;
    -e|--event_bus)
        EVENT_BUS=1
        shift
    ;;
    -*|--*=) # unsupported flags
      echo "Error: Unsupported flag $1" >&2
      exit 1
      ;;
    *) # preserve positional arguments
      PARAMS="$PARAMS $1"
      shift
      ;;
  esac
done

for a in ${MICROSERVICES[@]}; do
    echo "Microservice name $a"
    cd $REPOROOT/$a
    npm install
    if [ $? -ne 0 ]; then
        echo "something went wrong during NPM install of $a"
    fi

    if [ $a == "client" ];
    then
        npm build
        pm2 start --name $a src/index.js --time
    else 
        pm2 start --name $a index.js --time
    fi
    cd $REPOROOT
done

Leave a Reply

Your email address will not be published. Required fields are marked *