#!/bin/sh

export SERVICE_HOME=/home/cvim/test
export SERVICE_NAME=tsi-comm-server
export SERVICE_VERSION=0.0.1-SNAPSHOT
export EXE_NAME=$SERVICE_NAME-$SERVICE_VERSION.jar
export PID_NAME=$SERVICE_NAME.pid
export SERVICE_PID=$SERVICE_HOME/conf/$PID_NAME

cd $SERVICE_HOME

export JAVA_OPT="-server"
export JAVA_OPT="$JAVA_OPT -Xms4096m -Xmx4096m"
export JAVA_OPT="$JAVA_OPT -Xlog:gc*:file=logs/gc.log"
export CONFIG_OPT="--spring.config.location=conf//application.yml"

if [ ! -z "$SERVICE_PID" ]; then
  if [ -f "$SERVICE_PID" ]; then
    echo "$SERVICE_NAME is already running...."
    exit
  fi
fi

nohup java $JAVA_OPT -jar ./$EXE_NAME $CONFIG_OPT 1> /dev/null 2>&1 &

echo "$SERVICE_NAME is started...."

sleep 1

ps -eaf | grep $SERVICE_NAME | grep -v grep |wc -l

sleep 1

ps -eaf | grep $SERVICE_NAME | grep -v grep
