-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
367 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,8 @@ out | |
/reader-assets | ||
/.lh/ | ||
|
||
/simple-web/ | ||
/simple-web/ | ||
|
||
/server/logs | ||
/server/storage | ||
/server/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@echo off | ||
rem Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
rem you may not use this file except in compliance with the License. | ||
rem You may obtain a copy of the License at | ||
rem | ||
rem http://www.apache.org/licenses/LICENSE-2.0 | ||
rem | ||
rem Unless required by applicable law or agreed to in writing, software | ||
rem distributed under the License is distributed on an "AS IS" BASIS, | ||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
rem See the License for the specific language governing permissions and | ||
rem limitations under the License. | ||
if not exist "%JAVA_HOME%\bin\jps.exe" echo "Please set the JAVA_HOME variable in your environment, We need jdk8 or later!\n请设置 JAVA_HOME 环境变量,需要jdk8及以上的java环境!" & EXIT /B 1 | ||
|
||
setlocal | ||
|
||
set "PATH=%JAVA_HOME%\bin;%PATH%" | ||
|
||
echo killing reader server | ||
|
||
for /f "tokens=1" %%i in ('jps -m ^| find "reader.server"') do ( taskkill /F /PID %%i ) | ||
|
||
echo Done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
cd `dirname $0`/../target | ||
target_dir=`pwd` | ||
|
||
pid=`ps ax | grep -i 'reader.server' | grep ${target_dir} | grep java | grep -v grep | awk '{print $1}'` | ||
if [ -z "$pid" ] ; then | ||
echo "No reader running." | ||
exit -1; | ||
fi | ||
|
||
echo "The reader(${pid}) is running..." | ||
|
||
kill ${pid} | ||
|
||
echo "Send shutdown request to reader(${pid}) OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
@echo off | ||
rem Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
rem you may not use this file except in compliance with the License. | ||
rem You may obtain a copy of the License at | ||
rem | ||
rem http://www.apache.org/licenses/LICENSE-2.0 | ||
rem | ||
rem Unless required by applicable law or agreed to in writing, software | ||
rem distributed under the License is distributed on an "AS IS" BASIS, | ||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
rem See the License for the specific language governing permissions and | ||
rem limitations under the License. | ||
if not exist "%JAVA_HOME%\bin\java.exe" echo "请设置 JAVA_HOME 环境变量,需要jdk8及以上的java环境!" & EXIT /B 1 | ||
set "JAVA=%JAVA_HOME%\bin\java.exe" | ||
|
||
setlocal enabledelayedexpansion | ||
|
||
set BASE_DIR=%~dp0 | ||
rem added double quotation marks to avoid the issue caused by the folder names containing spaces. | ||
rem removed the last 5 chars(which means \bin\) to get the base DIR. | ||
set BASE_DIR="%BASE_DIR:~0,-5%" | ||
|
||
set CUSTOM_SEARCH_LOCATIONS=file:%BASE_DIR%/conf/ | ||
|
||
set SERVER=reader | ||
|
||
for /f "delims=" %%i in ('dir /b /o:-n %BASE_DIR%\target\reader*.jar') do set NEWEST_JAR=%%i | ||
|
||
if not "%NEWEST_JAR%"=="" ( | ||
set SERVER=%NEWEST_JAR:.jar=% | ||
) | ||
|
||
set SERVER %SERVER% | ||
set MODE="single" | ||
set INVITE_CODE="reader666" | ||
set SECURE_KEY="readersk" | ||
set MODE_INDEX=-1 | ||
set INVITE_CODE_INDEX=-1 | ||
set SERVER_INDEX=-1 | ||
set SECURE_KEY_INDEX=-1 | ||
set EMBEDDED_STORAGE="" | ||
|
||
|
||
set i=0 | ||
for %%a in (%*) do ( | ||
if "%%a" == "-m" ( set /a MODE_INDEX=!i!+1 ) | ||
if "%%a" == "-i" ( set /a INVITE_CODE_INDEX=!i!+1 ) | ||
if "%%a" == "-s" ( set /a SERVER_INDEX=!i!+1 ) | ||
if "%%a" == "-k" ( set /a SECURE_KEY_INDEX=!i!+1 ) | ||
set /a i+=1 | ||
) | ||
|
||
set i=0 | ||
for %%a in (%*) do ( | ||
if %MODE_INDEX% == !i! ( set MODE="%%a" ) | ||
if %INVITE_CODE_INDEX% == !i! ( set INVITE_CODE="%%a" ) | ||
if %SERVER_INDEX% == !i! (set SERVER="%%a") | ||
if %SECURE_KEY_INDEX% == !i! (set SECURE_KEY="%%a") | ||
set /a i+=1 | ||
) | ||
|
||
rem if reader startup mode is single | ||
if %MODE% == "single" ( | ||
echo "Reader 将以单用户模式运行" | ||
set "READER_JVM_OPTS=-Xms256m -Xmx256m -Xmn128m" | ||
) | ||
|
||
rem if reader startup mode is multi-user | ||
if not %MODE% == "single" ( | ||
echo "Reader 将以多用户模式运行。邀请码:%INVITE_CODE%,管理员密码:%SECURE_KEY%" | ||
set "READER_OPTS=-Dreader.app.secure=true -Dreader.app.inviteCode=%INVITE_CODE% -Dreader.app.secureKey=%SECURE_KEY%" | ||
|
||
set "READER_JVM_OPTS=-server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=160m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof -XX:-UseLargePages" | ||
) | ||
|
||
rem set reader options | ||
@REM set "READER_OPTS=%READER_OPTS% -Dloader.path=%BASE_DIR%/plugins,%BASE_DIR%/plugins/health,%BASE_DIR%/plugins/cmdb,%BASE_DIR%/plugins/selector" | ||
set "READER_OPTS=%READER_OPTS% -Dreader.app.workDir=%BASE_DIR%" | ||
set "READER_OPTS=%READER_OPTS% -jar %BASE_DIR%\target\%SERVER%.jar" | ||
|
||
rem set reader spring config location | ||
set "READER_CONFIG_OPTS=--spring.config.additional-location=%CUSTOM_SEARCH_LOCATIONS%" | ||
|
||
rem set reader log4j file location | ||
@REM set "READER_LOG4J_OPTS=--logging.config=%BASE_DIR%/conf/reader-logback.xml" | ||
|
||
|
||
set COMMAND="%JAVA%" %READER_JVM_OPTS% %READER_OPTS% %READER_CONFIG_OPTS% %READER_LOG4J_OPTS% reader.server %* | ||
|
||
echo %COMMAND% | ||
|
||
echo "Reader 正在启动中,你可以在 %BASE_DIR%\logs\start.out 查看日志" | ||
|
||
rem start reader command | ||
%COMMAND% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
cygwin=false | ||
darwin=false | ||
os400=false | ||
case "`uname`" in | ||
CYGWIN*) cygwin=true;; | ||
Darwin*) darwin=true;; | ||
OS400*) os400=true;; | ||
esac | ||
error_exit () | ||
{ | ||
echo "ERROR: $1 !!" | ||
exit 1 | ||
} | ||
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java | ||
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java | ||
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/opt/taobao/java | ||
[ ! -e "$JAVA_HOME/bin/java" ] && unset JAVA_HOME | ||
|
||
if [ -z "$JAVA_HOME" ]; then | ||
if $darwin; then | ||
|
||
if [ -x '/usr/libexec/java_home' ] ; then | ||
export JAVA_HOME=`/usr/libexec/java_home` | ||
|
||
elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then | ||
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" | ||
fi | ||
else | ||
JAVA_PATH=`dirname $(readlink -f $(which javac))` | ||
if [ "x$JAVA_PATH" != "x" ]; then | ||
export JAVA_HOME=`dirname $JAVA_PATH 2>/dev/null` | ||
fi | ||
fi | ||
if [ -z "$JAVA_HOME" ]; then | ||
error_exit "请设置 JAVA_HOME 环境变量,需要jdk8及以上的java环境!" | ||
fi | ||
fi | ||
|
||
export BASE_DIR=`cd $(dirname $0)/..; pwd` | ||
|
||
SERVER="reader" | ||
NEWEST_JAR=$(ls $BASE_DIR/target | grep -EO 'reader.*\.jar' | sort -nr | head -1) | ||
if [ -n "$NEWEST_JAR" ]; then | ||
SERVER=${NEWEST_JAR/.jar/} | ||
fi | ||
|
||
export SERVER | ||
export MODE="single" | ||
export INVITE_CODE="reader666" | ||
export SECURE_KEY="readersk" | ||
while getopts ":m:s:i:k:" opt | ||
do | ||
case $opt in | ||
m) | ||
MODE=$OPTARG;; | ||
s) | ||
SERVER=$OPTARG;; | ||
i) | ||
INVITE_CODE=$OPTARG;; | ||
k) | ||
SECURE_KEY=$OPTARG;; | ||
?) | ||
echo "未知的参数: $opt" | ||
exit 1;; | ||
esac | ||
done | ||
|
||
export JAVA_HOME | ||
export JAVA="$JAVA_HOME/bin/java" | ||
export CUSTOM_SEARCH_LOCATIONS=file:${BASE_DIR}/conf/ | ||
|
||
#=========================================================================================== | ||
# JVM Configuration | ||
#=========================================================================================== | ||
if [[ "${MODE}" == "single" ]]; then | ||
JAVA_OPT="${JAVA_OPT} -Xms256m -Xmx256m -Xmn128m" | ||
else | ||
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=160m" | ||
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof" | ||
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages" | ||
JAVA_OPT="${JAVA_OPT} -Dreader.app.secure=true -Dreader.app.inviteCode=${INVITE_CODE} -Dreader.app.secureKey=${SECURE_KEY}" | ||
fi | ||
|
||
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p') | ||
if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then | ||
JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/reader_gc.log:time,tags:filecount=10,filesize=100m" | ||
else | ||
JAVA_OPT_EXT_FIX="-Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext" | ||
JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/reader_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M" | ||
fi | ||
|
||
# JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins,${BASE_DIR}/plugins/health,${BASE_DIR}/plugins/cmdb,${BASE_DIR}/plugins/selector" | ||
JAVA_OPT="${JAVA_OPT} -Dreader.app.workDir=${BASE_DIR}" | ||
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/${SERVER}.jar" | ||
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}" | ||
JAVA_OPT="${JAVA_OPT} --spring.config.additional-location=${CUSTOM_SEARCH_LOCATIONS}" | ||
# JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml" | ||
JAVA_OPT="${JAVA_OPT} --server.max-http-header-size=524288" | ||
|
||
if [ ! -d "${BASE_DIR}/logs" ]; then | ||
mkdir ${BASE_DIR}/logs | ||
fi | ||
|
||
echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}" | ||
|
||
if [[ "${MODE}" == "single" ]]; then | ||
echo "Reader 将以单用户模式运行" | ||
else | ||
echo "Reader 将以多用户模式运行。邀请码:${INVITE_CODE},管理员密码:${SECURE_KEY}" | ||
fi | ||
|
||
# check the start.out log output file | ||
if [ ! -f "${BASE_DIR}/logs/start.out" ]; then | ||
touch "${BASE_DIR}/logs/start.out" | ||
else | ||
mv ${BASE_DIR}/logs/start.out ${BASE_DIR}/logs/start-$(date +'%Y-%m-%d_%H_%M').out | ||
fi | ||
# start | ||
echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 & | ||
|
||
if [[ "$JAVA_OPT_EXT_FIX" == "" ]]; then | ||
nohup "$JAVA" ${JAVA_OPT} reader.server >> ${BASE_DIR}/logs/start.out 2>&1 & | ||
else | ||
nohup "$JAVA" "$JAVA_OPT_EXT_FIX" ${JAVA_OPT} reader.server >> ${BASE_DIR}/logs/start.out 2>&1 & | ||
fi | ||
|
||
echo "Reader 正在启动中,你可以在 ${BASE_DIR}/logs/start.out 查看日志" |
Oops, something went wrong.