startup.sh
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/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`
SKRECEIVE_COMPONENT_HOME=`dirname "$PRG"`/..
# make it fully qualified
SKRECEIVE_COMPONENT_HOME=`cd "$SKRECEIVE_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=skreceive
# 开启远程调试
SKRECEIVE_DEBUG_ENABLE=false
export MODE=service
export PID_FOLDER="${SKRECEIVE_COMPONENT_HOME}"/logs
export LOG_FOLDER="${SKRECEIVE_COMPONENT_HOME}"/logs
export LOG_FILENAME="${SERVICE_NAME}.out"
export identity=${SERVICE_NAME}
if [ "x$SKRECEIVE_HEAP_OPTS" = "x" ]; then
SKRECEIVE_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 $SKRECEIVE_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' == "${SKRECEIVE_DEBUG_ENABLE}X" ]; then
if [ -z "${SKRECEIVE_DEBUG_PORT}" ]; then
SKRECEIVE_DEBUG_PORT=8787
fi
JAVA_OPTS="${JAVA_OPTS} -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${SKBOOT_DEBUG_PORT}"
fi
export JAVA_OPTS
# If exists private jdk
if [ -d "${SKRECEIVE_COMPONENT_HOME}/jdk" ] || [ -h "${SKRECEIVE_COMPONENT_HOME}/jdk" ] || [ -L "${SKRECEIVE_COMPONENT_HOME}/jdk" ]; then
export JAVA_HOME="${SKRECEIVE_COMPONENT_HOME}/jdk"
fi
RECEIVE_JAR=`echo "${SKRECEIVE_COMPONENT_HOME}"/*.jar`
if [ ! -x "${RECEIVE_JAR}" ]; then
chmod + "${RECEIVE_JAR}"
fi
if [ "x$FOREGROUND" = "xtrue" ]; then
export MODE=run
$RECEIVE_JAR "$@"
else
$RECEIVE_JAR start "$@"
fi