Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[type:refactor] Optimizing the startup script #5098

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
67432dc
[type:refactor] Optimizing the startup script
lahmXu Aug 29, 2023
f5e1d8b
Merge branch 'master' of https://github.com/apache/shenyu into optimi…
lahmXu Sep 1, 2023
337ac1c
Merge branch 'master' of https://github.com/apache/shenyu into optimi…
lahmXu Sep 1, 2023
52fbbfe
Merge branch 'master' into optimize_startup_script
damonxue Sep 9, 2023
2e345c9
Merge branch 'master' into optimize_startup_script
loongs-zhang Sep 19, 2023
9e21ed2
Merge branch 'master' into optimize_startup_script
loongs-zhang Sep 26, 2023
5d2a7a9
Merge branch 'master' into optimize_startup_script
yu199195 Oct 19, 2023
a001551
Merge branch 'master' into optimize_startup_script
loongs-zhang Jan 9, 2024
91402e7
Merge branch 'master' into optimize_startup_script
loongs-zhang Jan 17, 2024
0cc82e7
Merge branch 'master' into optimize_startup_script
Aias00 Aug 13, 2024
d898e86
Merge branch 'master' into optimize_startup_script
Aias00 Aug 18, 2024
ba75cfb
Merge branch 'master' into optimize_startup_script
Aias00 Aug 20, 2024
02d7199
Merge branch 'master' into optimize_startup_script
Aias00 Aug 21, 2024
9af9d84
Merge branch 'master' into optimize_startup_script
Aias00 Aug 23, 2024
d0d9a1c
Merge branch 'master' into optimize_startup_script
Aias00 Aug 29, 2024
bdc0ca8
Merge branch 'master' into optimize_startup_script
Aias00 Aug 31, 2024
4f1f346
Merge branch 'master' into optimize_startup_script
Aias00 Aug 31, 2024
5e04f69
Merge branch 'master' into optimize_startup_script
Aias00 Nov 20, 2024
6edb9ad
Merge branch 'master' into optimize_startup_script
Aias00 Dec 5, 2024
19039c4
Merge branch 'master' into optimize_startup_script
Aias00 Dec 5, 2024
7f9f222
Merge branch 'master' into optimize_startup_script
Aias00 Dec 6, 2024
e0e777a
Merge branch 'master' into optimize_startup_script
Aias00 Dec 9, 2024
f42f6fb
Merge branch 'master' into optimize_startup_script
Aias00 Dec 14, 2024
a63c936
Merge branch 'master' into optimize_startup_script
Aias00 Dec 17, 2024
be22c45
Merge branch 'master' into optimize_startup_script
Aias00 Dec 26, 2024
74dbc2c
Merge branch 'master' into optimize_startup_script
Aias00 Dec 26, 2024
681cf40
Merge branch 'master' into optimize_startup_script
Aias00 Dec 27, 2024
9cf8e68
Merge branch 'master' into optimize_startup_script
Aias00 Dec 31, 2024
0cda02e
Merge branch 'master' into optimize_startup_script
Aias00 Dec 31, 2024
7c1059e
Merge branch 'master' into optimize_startup_script
Aias00 Jan 2, 2025
d9b6971
Merge branch 'master' into optimize_startup_script
Aias00 Jan 2, 2025
e344307
Merge branch 'master' into optimize_startup_script
Aias00 Jan 3, 2025
ba60a36
Merge branch 'master' into optimize_startup_script
Aias00 Jan 6, 2025
393baac
Merge branch 'master' into optimize_startup_script
Aias00 Jan 9, 2025
d7af45f
Merge branch 'master' into optimize_startup_script
Aias00 Jan 13, 2025
5f17c03
Merge branch 'master' into optimize_startup_script
Aias00 Jan 14, 2025
5f276a0
Merge branch 'master' into optimize_startup_script
Aias00 Jan 15, 2025
c9469bd
Merge branch 'master' into optimize_startup_script
Aias00 Jan 16, 2025
15d783d
Merge branch 'master' into optimize_startup_script
Aias00 Jan 17, 2025
107d26a
Merge branch 'master' into optimize_startup_script
Aias00 Jan 18, 2025
8c88540
Merge branch 'master' into optimize_startup_script
Aias00 Jan 18, 2025
9418cff
Merge branch 'master' into optimize_startup_script
Aias00 Jan 20, 2025
b087446
Merge branch 'master' into optimize_startup_script
Aias00 Jan 21, 2025
573e960
Merge branch 'master' into optimize_startup_script
Aias00 Jan 21, 2025
beedae8
Merge branch 'master' into optimize_startup_script
Aias00 Jan 22, 2025
fc85576
Merge branch 'master' into optimize_startup_script
Aias00 Jan 22, 2025
fd91442
Merge branch 'master' into optimize_startup_script
Aias00 Jan 23, 2025
0391121
Merge branch 'master' into optimize_startup_script
Aias00 Jan 24, 2025
53d3980
Merge branch 'master' into optimize_startup_script
Aias00 Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions shenyu-dist/shenyu-admin-dist/src/main/resources/bin/run-class.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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`
cd ..
DEPLOY_DIR=`pwd`
EXT_LIB=${DEPLOY_DIR}/ext-lib
LIB=${DEPLOY_DIR}/lib

lib_regex="^"$LIB"/(java|jakarta|reactor|netty|tomcat|spring|mybatis|shenyu).*\.jar$"
lib_exclude_file() {
file=$1
if [ -z "$(echo "$file" | grep -E "$lib_regex")" ] ; then
return 0
else
return 1
fi
}

# conf files
for file in "$DEPLOY_DIR"/conf/*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

# lib files
for file in "$DEPLOY_DIR"/lib/java*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/jakarta*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/reactor*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/netty*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/tomcat*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/spring*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/mybatis*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/shenyu*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/*;
do
if lib_exclude_file "$file"; then
CLASS_PATH="$CLASS_PATH":"$file"
fi
done

# ext_lib files
for file in "$EXT_LIB"/*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi

nohup "$JAVA" -cp "$CLASS_PATH" "$@"

9 changes: 3 additions & 6 deletions shenyu-dist/shenyu-admin-dist/src/main/resources/bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ LOGS_DIR=${DEPLOY_DIR}/logs
if [ ! -d ${LOGS_DIR} ]; then
mkdir ${LOGS_DIR}
fi

LOG_FILES=${LOGS_DIR}/shenyu-admin.log
EXT_LIB=${DEPLOY_DIR}/ext-lib

CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
if [ -z "${ADMIN_JVM}" ]; then
JAVA_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss328k -XX:+DisableExplicitGC -XX:LargePageSizeInBytes=128m"
version=`java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}'`
Expand All @@ -49,8 +46,8 @@ else
fi

MAIN_CLASS=org.apache.shenyu.admin.ShenyuAdminBootstrap
echo "Starting the $SERVER_NAME ..."

nohup java ${JAVA_OPTS} -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${LOG_FILES} 2>&1 &
sleep 1
echo "Starting the $SERVER_NAME ..."
echo "Please check the log files: $LOG_FILES"

exec $DEPLOY_DIR/bin/run-class.sh $JAVA_OPTS $MAIN_CLASS >> $LOG_FILES 2>&1 & "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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`
cd ..
DEPLOY_DIR=`pwd`
EXT_LIB=${DEPLOY_DIR}/ext-lib
LIB=${DEPLOY_DIR}/lib

lib_regex="^"$LIB"/(java|jakarta|jackson|reactor|netty|spring|shenyu).*\.jar$"
lib_exclude_file() {
file=$1
if [ -z "$(echo "$file" | grep -E "$lib_regex")" ] ; then
return 0
else
return 1
fi
}

# conf files
for file in "$DEPLOY_DIR"/conf/*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

# lib files
for file in "$DEPLOY_DIR"/lib/java*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/jakarta*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/jackson*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/reactor*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/netty*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/spring*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/shenyu*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

for file in "$DEPLOY_DIR"/lib/*;
do
if lib_exclude_file "$file"; then
CLASS_PATH="$CLASS_PATH":"$file"
fi
done

# ext_lib files
for file in "$EXT_LIB"/*;
do
CLASS_PATH="$CLASS_PATH":"$file"
done

if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi

nohup "$JAVA" -cp "$CLASS_PATH" "$@"

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ if [ ! -d ${LOGS_DIR} ]; then
fi

LOG_FILES=${LOGS_DIR}/shenyu-bootstrap.log
EXT_LIB=${DEPLOY_DIR}/ext-lib

CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
if [ -z "${BOOT_JVM}" ]; then
JAVA_OPTS=" -server -Xmx4g -Xms4g -Xmn1g -Xss512k -XX:+DisableExplicitGC -XX:LargePageSizeInBytes=128m"
version=`java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}'`
Expand All @@ -51,8 +49,6 @@ fi
MAIN_CLASS=org.apache.shenyu.bootstrap.ShenyuBootstrapApplication

echo "Starting the $SERVER_NAME ..."

nohup java ${JAVA_OPTS} -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${LOG_FILES} 2>&1 &

sleep 1
echo "Please check the log files: $LOG_FILES"

exec $DEPLOY_DIR/bin/run-class.sh $JAVA_OPTS $MAIN_CLASS >> $LOG_FILES 2>&1 & "$@"
Loading