Skip to content

Commit 42a3931

Browse files
committed
Fix Windows script to handle return code properly
1 parent b692a73 commit 42a3931

File tree

9 files changed

+39
-32
lines changed

9 files changed

+39
-32
lines changed

bin/mqadmin.cmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,5 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%ROCKETMQ_HOME%\bin\tools.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & goto end
18-
call "%ROCKETMQ_HOME%\bin\tools.cmd" org.apache.rocketmq.tools.command.MQAdminStartup %*
19-
20-
:end
17+
if not exist "%ROCKETMQ_HOME%\bin\tools.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1
18+
call "%ROCKETMQ_HOME%\bin\tools.cmd" org.apache.rocketmq.tools.command.MQAdminStartup %*

bin/mqbroker.cmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%ROCKETMQ_HOME%\bin\runbroker.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & goto end
17+
if not exist "%ROCKETMQ_HOME%\bin\runbroker.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1
1818

1919
call "%ROCKETMQ_HOME%\bin\runbroker.cmd" org.apache.rocketmq.broker.BrokerStartup %*
2020

21-
:end
21+
IF %ERRORLEVEL% EQU 0 (
22+
ECHO "Broker starts OK"
23+
)

bin/mqfiltersrv.cmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%ROCKETMQ_HOME%\bin\runbroker.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & goto end
17+
if not exist "%ROCKETMQ_HOME%\bin\runbroker.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1
1818

1919
call "%ROCKETMQ_HOME%\bin\runserver.cmd" org.apache.rocketmq.filtersrv.FiltersrvStartup %*
2020

21-
:end
21+
IF %ERRORLEVEL% EQU 0 (
22+
ECHO "Filtersrv starts OK"
23+
)

bin/mqnamesrv.cmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%ROCKETMQ_HOME%\bin\runserver.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & goto end
17+
if not exist "%ROCKETMQ_HOME%\bin\runserver.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1
1818

1919
call "%ROCKETMQ_HOME%\bin\runserver.cmd" org.apache.rocketmq.namesrv.NamesrvStartup %*
2020

21-
:end
21+
IF %ERRORLEVEL% EQU 0 (
22+
ECHO "Namesrv starts OK"
23+
)

bin/mqshutdown.cmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & goto end
17+
if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
1818

1919
setlocal
2020

@@ -32,6 +32,4 @@ if /I "%1" == "broker" (
3232
echo Done!
3333
) else (
3434
echo Unknown role to kill, please specify broker or namesrv
35-
)
36-
37-
:end
35+
)

bin/play.cmd

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
START /B mqnamesrv > ns.log
18-
START /B mqbroker -n localhost:9876 > bk.log
17+
START /B mqnamesrv > ns.log 2>&1
18+
IF %ERRORLEVEL% NEQ 0 (
19+
echo "Failed to start name server. Please check ns.log"
20+
EXIT /B 1
21+
)
22+
23+
START /B mqbroker -n localhost:9876 > bk.log 2>&1
24+
25+
IF %ERRORLEVEL% NEQ 0 (
26+
ECHO "Failed to start broker. Please check bk.log"
27+
EXIT /B 1
28+
)
29+
1930
echo "Start Name Server and Broker Successfully."

bin/runbroker.cmd

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & goto end
17+
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
1818
set "JAVA=%JAVA_HOME%\bin\java.exe"
1919

2020
setlocal
@@ -28,9 +28,9 @@ set CLASSPATH=.;%BASE_DIR%conf;%CLASSPATH%
2828
rem ===========================================================================================
2929
rem JVM Configuration
3030
rem ===========================================================================================
31-
set "JAVA_OPT=%JAVA_OPT% -server -Xms8g -Xmx8g -Xmn4g"
31+
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g"
3232
set "JAVA_OPT=%JAVA_OPT% -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8 -XX:+DisableExplicitGC"
33-
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:%HOMEPATH%\mq_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
33+
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:%USERPROFILE%\mq_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
3434
set "JAVA_OPT=%JAVA_OPT% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
3535
set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
3636
set "JAVA_OPT=%JAVA_OPT% -XX:+AlwaysPreTouch"
@@ -39,6 +39,4 @@ set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages -XX:-UseBiasedLocking"
3939
set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib"
4040
set "JAVA_OPT=%JAVA_OPT% -cp %CLASSPATH%"
4141

42-
"%JAVA%" %JAVA_OPT% %*
43-
44-
:end
42+
"%JAVA%" %JAVA_OPT% %*

bin/runserver.cmd

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

1717

18-
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & goto end
18+
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
1919
set "JAVA=%JAVA_HOME%\bin\java.exe"
2020

2121
setlocal
@@ -26,14 +26,12 @@ for %%d in (%BASE_DIR%) do set BASE_DIR=%%~dpd
2626

2727
set CLASSPATH=.;%BASE_DIR%conf;%CLASSPATH%
2828

29-
set "JAVA_OPT=%JAVA_OPT% -server -Xms4g -Xmx4g -Xmn2g -XX:PermSize=128m -XX:MaxPermSize=320m"
29+
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:PermSize=128m -XX:MaxPermSize=320m"
3030
set "JAVA_OPT=%JAVA_OPT% -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -XX:-UseParNewGC"
31-
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:"%HOMEPATH%\rmq_srv_gc.log" -XX:+PrintGCDetails"
31+
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:"%USERPROFILE%\rmq_srv_gc.log" -XX:+PrintGCDetails"
3232
set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
3333
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
3434
set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib"
3535
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
3636

37-
"%JAVA%" %JAVA_OPT% %*
38-
39-
:end
37+
"%JAVA%" %JAVA_OPT% %*

bin/tools.cmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
rem See the License for the specific language governing permissions and
1515
rem limitations under the License.
1616

17-
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & goto end
17+
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
1818

1919
set "JAVA=%JAVA_HOME%\bin\java.exe"
2020

@@ -32,6 +32,4 @@ set "JAVA_OPT=%JAVA_OPT% -server -Xms1g -Xmx1g -Xmn256m -XX:PermSize=128m -XX:Ma
3232
set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs="%BASE_DIR%\lib";"%JAVA_HOME%\jre\lib\ext""
3333
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
3434

35-
"%JAVA%" %JAVA_OPT% %*
36-
37-
:end
35+
"%JAVA%" %JAVA_OPT% %*

0 commit comments

Comments
 (0)