Skip to content

Commit 48c108c

Browse files
Little-Peonyclaude
andcommitted
revert(scripts): restore start.sh, start.sh.simple, ver.sh to develop baseline
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e5d5f71 commit 48c108c

3 files changed

Lines changed: 32 additions & 52 deletions

File tree

start.sh

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if [ -z "$JAVA_HOME" ]; then
7777
# readlink(1) is not available as standard on Solaris 10.
7878
readLink=`which readlink`
7979
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
80-
if [[ "$(uname)" == "Darwin" ]]; then
80+
if $darwin ; then
8181
javaHome="`dirname \"$javaExecutable\"`"
8282
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
8383
else
@@ -135,7 +135,7 @@ backupGCLog() {
135135
local oldGcLogFiles=(`ls -1 $gcLogDir |head -n $oldFileSize`)
136136
fi
137137

138-
for fileName in "${oldGcLogFiles[@]}"; do
138+
for fileName in ${oldGcLogFiles[@]}; do
139139
rm -rf $gcLogDir$fileName
140140
done
141141
fi
@@ -151,7 +151,7 @@ getLatestReleaseVersion() {
151151
}
152152

153153
checkVersion() {
154-
github_release_version=$(getLatestReleaseVersion)
154+
github_release_version=$(`echo getLatestReleaseVersion`)
155155
if [[ -n $github_release_version ]]; then
156156
echo "info: github latest version: $github_release_version"
157157
echo $github_release_version
@@ -162,7 +162,7 @@ checkVersion() {
162162
}
163163

164164
upgrade() {
165-
latest_version=$(getLatestReleaseVersion)
165+
latest_version=$(`echo getLatestReleaseVersion`)
166166
echo "info: latest version: $latest_version"
167167
if [[ -n $latest_version ]]; then
168168
old_jar="$PWD/$JAR_NAME"
@@ -204,7 +204,7 @@ mkdirFullNode() {
204204
}
205205

206206
quickStart() {
207-
full_node_version=$(getLatestReleaseVersion)
207+
full_node_version=$(`echo getLatestReleaseVersion`)
208208
if [[ -n $full_node_version ]]; then
209209
mkdirFullNode
210210
echo "info: check latest version: $full_node_version"
@@ -224,7 +224,7 @@ quickStart() {
224224
cloneCode() {
225225
if type git >/dev/null 2>&1; then
226226
git_clone=$(git clone -b $GITHUB_BRANCH $GITHUB_REPOSITORY)
227-
if [[ $? == 0 ]]; then
227+
if [[ git_clone == 0 ]]; then
228228
echo 'info: git clone java-tron success'
229229
fi
230230
else
@@ -255,22 +255,18 @@ checkPid() {
255255
JAR_NAME=$(echo $JAR_NAME |awk -F '/' '{print $NF}')
256256
fi
257257
pid=$(ps -ef | grep -v start | grep $JAR_NAME | grep -v grep | awk '{print $2}')
258+
return $pid
258259
}
259260

260261
stopService() {
261-
checkPid
262-
if [ ! "$pid" ]; then
263-
echo "info: java-tron is not running"
264-
return
265-
fi
266262
count=1
267263
while [ $count -le $MAX_STOP_TIME ]; do
268264
checkPid
269-
if [ "$pid" ]; then
265+
if [ $pid ]; then
270266
kill -15 $pid
271267
sleep 1
272268
else
273-
echo "info: java-tron stopped"
269+
echo "info: java-tron stop"
274270
return
275271
fi
276272
count=$(($count + 1))
@@ -284,7 +280,7 @@ stopService() {
284280

285281
checkAllowMemory() {
286282
os=`uname`
287-
totalMemory=$(getTotalMemory)
283+
totalMemory=$(`echo getTotalMemory`)
288284
total=`expr $totalMemory / 1024`
289285
if [[ $os == 'Darwin' ]]; then
290286
return
@@ -321,23 +317,23 @@ getTotalMemory() {
321317
echo $total
322318
return
323319
elif [[ $os == 'Darwin' ]]; then
324-
total=$(sysctl -n hw.memsize)
325-
echo $(( total / 1024 ))
320+
total=$(sysctl -a | grep mem |grep hw.memsize |awk -F ' ' '{print $2}')
321+
echo `expr $total / 1024`
326322
fi
327323
}
328324

329325
setJVMMemory() {
330326
os=`uname`
331327
if [[ $os == 'Linux' ]] || [[ $os == 'linux' ]] ; then
332-
if [[ $SPECIFY_MEMORY -gt 0 ]]; then
328+
if [[ $SPECIFY_MEMORY >0 ]]; then
333329
max_direct=$(echo "$SPECIFY_MEMORY/1024*0.1" | bc | awk -F. '{print $1"g"}')
334330
if [[ "$max_direct" != "g" ]]; then
335331
MAX_DIRECT_MEMORY=$max_direct
336332
fi
337333
JVM_MX=$(echo "$SPECIFY_MEMORY/1024*0.6" | bc | awk -F. '{print $1"g"}')
338334
JVM_MS=$JVM_MX
339335
else
340-
total=$(getTotalMemory)
336+
total=$(`echo getTotalMemory`)
341337
MAX_DIRECT_MEMORY=$(echo "$total/1024/1024*0.1" | bc | awk -F. '{print $1"g"}')
342338
JVM_MX=$(echo "$total/1024/1024*0.6" | bc | awk -F. '{print $1"g"}')
343339
JVM_MS=$JVM_MX
@@ -359,10 +355,8 @@ startService() {
359355
exit
360356
fi
361357

362-
# G1GC is used here for JDK 8/17 compatibility. CMS flags (-XX:+UseConcMarkSweepGC etc.)
363-
# were removed in JDK 14 and cause JVM startup failure on JDK 17 (required for ARM64).
364-
nohup $JAVACMD -Xms$JVM_MS -Xmx$JVM_MX -XX:+UseG1GC -XX:+PrintGCDetails -Xloggc:./gc.log \
365-
-XX:+PrintGCDateStamps -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing \
358+
nohup $JAVACMD -Xms$JVM_MS -Xmx$JVM_MX -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:./gc.log \
359+
-XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing \
366360
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
367361
-XX:MaxDirectMemorySize=$MAX_DIRECT_MEMORY -XX:+HeapDumpOnOutOfMemoryError \
368362
-XX:NewRatio=2 -jar \
@@ -389,9 +383,9 @@ rebuildManifest() {
389383
$JAVACMD -jar $ARCHIVE_JAR -d $REBUILD_DIR -m $REBUILD_MANIFEST_SIZE -b $REBUILD_BATCH_SIZE
390384
else
391385
echo 'info: download the rebuild manifest plugin from the github'
392-
local latest=$(getLatestReleaseVersion)
386+
local latest=$(`echo getLatestReleaseVersion`)
393387
download $RELEASE_URL/download/GreatVoyage-v"$latest"/$ARCHIVE_JAR $ARCHIVE_JAR
394-
if [[ $? == 0 ]]; then
388+
if [[ $download == 0 ]]; then
395389
echo 'info: download success, rebuild manifest'
396390
$JAVACMD -jar $ARCHIVE_JAR $REBUILD_DIR -m $REBUILD_MANIFEST_SIZE -b $REBUILD_BATCH_SIZE
397391
fi
@@ -412,7 +406,7 @@ specifyConfig(){
412406
elif [[ "$netType" = 'private' ]]; then
413407
configName=$FULL_NODE_CONFIG_PRIVATE_NET
414408
else
415-
echo "warn: no support config $netType"
409+
echo "warn: no support config $nodeType"
416410
exit
417411
fi
418412

@@ -422,7 +416,7 @@ specifyConfig(){
422416

423417
if [[ -d $FULL_NODE_CONFIG_DIR/$configName ]]; then
424418
DEFAULT_FULL_NODE_CONFIG=$FULL_NODE_CONFIG_DIR/$configName
425-
return
419+
break
426420
fi
427421

428422
if [[ ! -f $FULL_NODE_CONFIG_DIR/$configName ]]; then
@@ -434,7 +428,7 @@ specifyConfig(){
434428

435429
checkSign() {
436430
echo 'info: verify signature'
437-
local latest_version=$(getLatestReleaseVersion)
431+
local latest_version=$(`echo getLatestReleaseVersion`)
438432
download $RELEASE_URL/download/$latest_version/sha256sum.txt sha256sum.txt
439433
fullNodeSha256=$(cat sha256sum.txt|grep 'FullNode'| awk -F ' ' '{print $1}')
440434

@@ -548,14 +542,12 @@ while [ -n "$1" ]; do
548542
--run)
549543
if [[ $ALL_OPT_LENGTH -eq 1 ]]; then
550544
restart
551-
exit
552545
fi
553546
RUN=true
554547
shift 1
555548
;;
556549
--stop)
557550
stopService
558-
exit
559551
;;
560552
FullNode)
561553
RUN=true
@@ -611,7 +603,7 @@ if [[ $UPGRADE == true ]]; then
611603
fi
612604

613605
if [[ $DOWNLOAD == true ]]; then
614-
latest=$(getLatestReleaseVersion)
606+
latest=$(`echo getLatestReleaseVersion`)
615607
if [[ -n $latest ]]; then
616608
download $RELEASE_URL/download/$latest/$JAR_NAME $latest
617609
exit
@@ -620,7 +612,11 @@ if [[ $DOWNLOAD == true ]]; then
620612
fi
621613
fi
622614

623-
if [[ $ALL_OPT_LENGTH -eq 0 || $RUN == true ]]; then
615+
if [[ $ALL_OPT_LENGTH -eq 0 || $ALL_OPT_LENGTH -gt 0 ]]; then
616+
restart
617+
fi
618+
619+
if [[ $RUN == true ]]; then
624620
restart
625621
fi
626622

start.sh.simple

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ VM_XMX="9G"
3737

3838
FULL_NODE_JAR="FullNode.jar"
3939
FULL_START_OPT=()
40-
GC_OPTS=()
4140
PID=""
4241
MAX_STOP_TIME=60
4342
JAVACMD=""
@@ -80,22 +79,6 @@ findJava() {
8079
which java >/dev/null 2>&1 || die "JAVA_HOME not set and no 'java' in PATH"
8180
fi
8281
"$JAVACMD" -version > /dev/null 2>&1 || die "Java command not working"
83-
84-
# Detect JVM major version to choose compatible GC flags
85-
local ver
86-
ver=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}')
87-
local major
88-
major=$(echo "$ver" | cut -d'.' -f1)
89-
[ "$major" = "1" ] && major=$(echo "$ver" | cut -d'.' -f2) # JDK 8 reports "1.8.x"
90-
if [ "$major" -eq 8 ] 2>/dev/null; then
91-
# CMS is optimal for JDK 8 (removed in JDK 14)
92-
GC_OPTS=(-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
93-
-XX:+PrintGCDetails "-Xloggc:./gc.log" -XX:+PrintGCDateStamps)
94-
else
95-
# ZGC (stable since JDK 15) + unified GC logging (JDK 9+), for JDK 17
96-
GC_OPTS=(-XX:+UseZGC
97-
"-Xlog:gc,gc+heap:file=gc.log:time,tags,level:filecount=10,filesize=100M")
98-
fi
9982
}
10083

10184
checkPid() {
@@ -147,7 +130,8 @@ startService() {
147130

148131
nohup "$JAVACMD" \
149132
-Xmx"$VM_XMX" \
150-
"${GC_OPTS[@]}" \
133+
-XX:+UseZGC \
134+
-Xlog:gc,gc+heap:file=gc.log:time,tags,level:filecount=10,filesize=100M \
151135
-XX:ReservedCodeCacheSize=256m \
152136
-XX:+UseCodeCacheFlushing \
153137
-XX:MetaspaceSize=256m \

ver.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
cd "$(dirname "$0")"
3-
currentBranch=$(git rev-parse --abbrev-ref HEAD)
2+
set -x
3+
currentBranch=`git rev-parse --abbrev-ref HEAD`
44

55
if [ "$currentBranch"x != "master"x ]
66
then
@@ -24,7 +24,7 @@ then
2424
fi
2525

2626

27-
versionPath="framework/src/main/java/org/tron/program/Version.java"
27+
versionPath="src/main/java/org/tron/program/Version.java"
2828
sed -i -e "s/VERSION_NAME.*$/VERSION_NAME = \"$versionName\";/g;s/VERSION_CODE.*$/VERSION_CODE = \"$versionCode\";/g" $versionPath
2929
git add $versionPath
3030
git commit -m "update a new version. version name:$versionName,version code:$versionCode"

0 commit comments

Comments
 (0)