Add the .bat script for start/stop discovery
[msb/discovery.git] / sdclient / discovery-standalone / src / assembly / resources / discover / run.bat
1 @REM
2 @REM Copyright (C) 2018 ZTE, Inc. and others. All rights reserved. (ZTE)
3 @REM
4 @REM Licensed under the Apache License, Version 2.0 (the "License");
5 @REM you may not use this file except in compliance with the License.
6 @REM You may obtain a copy of the License at
7 @REM
8 @REM         http://www.apache.org/licenses/LICENSE-2.0
9 @REM
10 @REM Unless required by applicable law or agreed to in writing, software
11 @REM distributed under the License is distributed on an "AS IS" BASIS,
12 @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 @REM See the License for the specific language governing permissions and
14 @REM limitations under the License.
15 @REM
16
17
18 @echo off
19
20 set RUNHOME=%~dp0%
21 echo ### RUNHOME: %RUNHOME%
22
23 if exist "%RUNHOME%setenv.bat" (
24   call "%RUNHOME%setenv.bat"
25 )
26
27
28 echo ================== ENV_INFO  =============================================
29 echo RUNHOME=%RUNHOME%
30 echo JAVA_BASE=%JAVA_BASE%
31 echo Main_Class=%Main_Class%
32 echo APP_INFO=%APP_INFO%
33 echo Main_JAR=%Main_JAR%
34 echo Main_Conf=%Main_Conf%
35 echo ==========================================================================
36
37 title %APP_INFO%
38 echo ### Starting %APP_INFO%
39
40 IF EXIST "%JAVA_BASE%" (
41 set JAVA_HOME=%JAVA_BASE%
42 )
43
44 set JAVA="%JAVA_HOME%/bin/java"
45 set JAVA_OPTS=-Xms50m -Xmx128m
46 set port=8778
47
48 setlocal enabledelayedexpansion
49 set index=1
50 FOR /F "tokens=3 delims= " %%a in ('"%JAVA% -version 2>&1"')do (
51   if !index! equ 1 set JAVA_VERSION=%%a
52   set /a index=index+1
53 )
54 set JAVA_VERSION=%JAVA_VERSION:~1,3%
55 if "%JAVA_VERSION%"=="1.8" (
56    set jvm_opts=-Xms16m -Xmx128m -XX:+UseSerialGC -XX:MaxMetaspaceSize=64m  -XX:NewRatio=2 
57 ) else (
58    set jvm_opts=-Xms16m -Xmx128m -XX:+UseSerialGC  -XX:MaxPermSize=64m -XX:NewRatio=2
59 )
60
61 set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n
62
63 set CLASS_PATH=%RUNHOME%;%RUNHOME%%Main_JAR%
64
65
66 echo ================== RUN_INFO  =============================================
67 echo ### JAVA_HOME: %JAVA_HOME%
68 echo ### JAVA: %JAVA%
69 echo ### jvm_opts: %jvm_opts%
70 echo ### class_path: %CLASS_PATH%
71 echo ### EXT_DIRS: %EXT_DIRS%
72 echo ==========================================================================
73
74 cd /d %RUNHOME%
75
76 echo @JAVA@ %JAVA%
77 echo @JAVA_CMD@
78 %JAVA% -classpath %CLASS_PATH% %jvm_opts% %Main_Class% server %RUNHOME%/%Main_Conf%
79
80 IF ERRORLEVEL 1 goto showerror
81 exit
82 :showerror
83 echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!
84 echo After checking, press any key to close 
85 pause
86 exit