Skip to content

Commit c147997

Browse files
authored
Merge pull request #4713 from forfreeday/feature/update_shell
feat(shell): update start.sh
2 parents 161e4ca + f68f12f commit c147997

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

start.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ALLOW_MIN_MEMORY=8192
4646
MAX_DIRECT_MEMORY=1g
4747
JVM_MS=4g
4848
JVM_MX=4g
49+
IS_BACKUP_GC_LOG=true
4950

5051
SPECIFY_MEMORY=0
5152
RUN=false
@@ -113,6 +114,32 @@ if [ -z "$JAVA_HOME" ] ; then
113114
echo "Warning: JAVA_HOME environment variable is not set."
114115
fi
115116

117+
backupGCLog() {
118+
local maxFile=5
119+
local gcLogDir=logs/gc_logs/
120+
if [ ! -d "$gcLogDir" ];then
121+
mkdir -p 'logs/gc_logs'
122+
fi
123+
124+
if [ -f 'gc.log' ]; then
125+
echo '[info] backup gc.log'
126+
local dateformat=`date "+%Y-%m-%d_%H-%M-%S"`
127+
tar -czvf gc.log_$dateformat'.tar.gz' gc.log
128+
mv gc.log_$dateformat'.tar.gz' $gcLogDir
129+
rm -rf gc.log
130+
131+
# checking the number of backups
132+
local currentDirCount=`ls -l $gcLogDir | grep "gc.log*" | wc -l`
133+
if [ $currentDirCount -gt $maxFile ]; then
134+
local oldFileSize=`expr $currentDirCount - $maxFile`
135+
local oldGcLogFiles=(`ls -1 $gcLogDir |head -n $oldFileSize`)
136+
fi
137+
138+
for fileName in ${oldGcLogFiles[@]}; do
139+
rm -rf $gcLogDir$fileName
140+
done
141+
fi
142+
}
116143

117144
getLatestReleaseVersion() {
118145
full_node_version=`git ls-remote --tags $GITHUB_REPOSITORY |grep GreatVoyage- | awk -F '/' 'END{print $3}'`
@@ -553,6 +580,10 @@ while [ -n "$1" ]; do
553580
esac
554581
done
555582

583+
if [[ $IS_BACKUP_GC_LOG = true ]]; then
584+
backupGCLog
585+
fi
586+
556587
if [[ $CLONE_BUILD == true ]];then
557588
cloneBuild
558589
fi

0 commit comments

Comments
 (0)