#!/usr/bin/sh

if [ -z "$MWMS_BASE" ] ; then
  echo "MWMS_BASE not found."
fi

### ADD MWMS_OPTS
if [ -z "$JAVA_OPTS" ] ; then
  JAVA_OPTS=
fi
JAVA_OPTS=" -Xms$3 -Xmx$4 -server "
### MWMS_OPTS
IDMFRAME_FLOW_BPELJ=http://bpel.boe.com/bpelj
COMPANY=BOE
FACTORY=ZXY
CIM=MWMS
SVR=$1

if [ $SVR != 'CNMsvr' ] && [ $SVR != 'QRYsvr' ];then
	LOCAL=\_LOCAL\.
fi

if [ `hostname` = 'vastbase' ]
    then
		MODE=DEV
	elif [ `hostname` = 'G3.5TestAP1' ]
	then
		MODE=TST
	else
		MODE=PRD
fi

if [ `hostname` = 'mdlap1' ] 
    then
		SEQ="$SVR"1"$2"
	elif [ `hostname` = 'mdlap2' ]
	then
		SEQ="$SVR"2"$2"
	elif [ `hostname` = 'md1ap3' ]
	then
		SEQ="$SVR"3"$2"
	else
		SEQ="$SVR"1"$2"
fi


echo $1 $2 $3 $4

if [ -z "$CONFIG_ROOT_PATH" ] ; then
  CONFIG_ROOT_PATH="$MWMS_BASE"/conf
fi

if [ -z "$LOGDIR" ] ; then
  LOGDIR="$MWMS_BASE"/logs
fi

if [ -z "$MWMS_OPTS" ] ; then
  MWMS_OPTS=
fi

if [[ ! -d $LOGDIR/$SVR/gc ]] ; then
  mkdir -p $LOGDIR/$SVR/gc
fi

if [[ ! -d "$LOGDIR/$SVR/jvmstoplog" ]] ; then
  mkdir -p "$LOGDIR/$SVR/jvmstoplog"
fi

MWMS_OPTS="-DconfigRootPath=$CONFIG_ROOT_PATH -Dcompany=$COMPANY -Dfactory=$FACTORY -Dcim=$CIM -Dmode=$MODE -Dtypemode=Prd -Dsvr=$SVR -DSeq=$SEQ -Didmframe.flow.bpelj=$IDMFRAME_FLOW_BPELJ -DLOGDIR=$LOGDIR -DworkerWeight=2 -DworkerTasks=1 -DschedulerWeight=10 -Ddq=DQ -Dlocal=$LOCAL -Dnetwork=$5 -Dservice=$6 -Ddaemon= "
JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC -XX:+UseStringDeduplication -verbose:gc -Xloggc:$LOGDIR/$SVR/gc/$SEQ.gc -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$LOGDIR/$SVR/jvmstoplog/ -XX:ErrorFile=$LOGDIR/jvmstoplog/$SEQ.log "
#echo "$MWMS_OPTS"
#echo "$JAVA_OPTS"
