startup.sh 2.5 KB
#!/bin/bash

#
# Copyright (c) 2001-2019 kingtroldata, Ltd.
# All rights reserved.
#
# author: liyuanyuan (mailto:yuanyuan.li@kingtroldata.com)
#

## resolve links
PRG="$0"

# need this for relative symlinks
while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG="`dirname "$PRG"`/$link"
  fi
done

saveddir=`pwd`

FMBOOT_COMPONENT_HOME=`dirname "$PRG"`/..

# make it fully qualified
FMBOOT_COMPONENT_HOME=`cd "$FMBOOT_COMPONENT_HOME" && pwd`

cd "$saveddir"

# If you start multiple instances on a single host, you need to modify this service name to avoid conflicts.
SERVICE_NAME=fmboot

#	开启远程调试
FMBOOT_DEBUG_ENABLE=false

export MODE=service
export PID_FOLDER="${FMBOOT_COMPONENT_HOME}"/logs
export LOG_FOLDER="${FMBOOT_COMPONENT_HOME}"/logs
export LOG_FILENAME="${SERVICE_NAME}.out"
export identity=${SERVICE_NAME}

if [ "x$FMBOOT_HEAP_OPTS" = "x" ]; then
    FMBOOT_HEAP_OPTS="-Xms2048M -Xmx2048M"
fi

mkdir -p $LOG_FOLDER
#ln -s /dev/null $LOG_FOLDER/$LOG_FILENAME 2>/dev/null 
#JAVA_OPTS="$JAVA_OPTS -Dlogging.file=$LOG_FOLDER/$SERVICE_NAME.log"
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Beijing -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"
JAVA_OPTS="$JAVA_OPTS $FMBOOT_HEAP_OPTS"
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow"
JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+UseConcMarkSweepGC "
# JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:$LOG_FOLDER/heap_trace.txt -XX:HeapDumpPath=$LOG_FOLDER/HeapDumpOnOutOfMemoryError/"
JAVA_OPTS="$JAVA_OPTS -Dlog.path=$LOG_FOLDER"

# if debug enabled
if [ 'trueX' == "${FMBOOT_DEBUG_ENABLE}X" ]; then
  if [ -z "${FMBOOT_DEBUG_PORT}" ]; then
    FMBOOT_DEBUG_PORT=8787
  fi
  JAVA_OPTS="${JAVA_OPTS} -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${FMBOOT_DEBUG_PORT}"
fi

export JAVA_OPTS

# If exists private jdk
if [ -d "${FMBOOT_COMPONENT_HOME}/jdk" ] || [ -h "${FMBOOT_COMPONENT_HOME}/jdk" ] || [ -L "${FMBOOT_COMPONENT_HOME}/jdk" ]; then
  export JAVA_HOME="${FMBOOT_COMPONENT_HOME}/jdk"
fi


BOOT_JAR=`echo "${FMBOOT_COMPONENT_HOME}"/*.jar`
if [ ! -x "${BOOT_JAR}" ]; then
  chmod + "${BOOT_JAR}"
fi
if [ "x$FOREGROUND" = "xtrue" ]; then
  export MODE=run
  $BOOT_JAR "$@"
else
  $BOOT_JAR start "$@"
fi