Merge "Bug 1306: Fixed incorrect AD/MD-SAL flow conversion."
[controller.git] / opendaylight / distribution / opendaylight / src / main / resources / run.bat
1 @ECHO OFF
2 SETLOCAL ENABLEDELAYEDEXPANSION
3
4 IF NOT EXIST "%JAVA_HOME%" (
5     ECHO JAVA_HOME environment variable is not set
6     EXIT /B 2
7 )
8
9 SET basedir=%~dp0
10 SET debugport=8000
11 SET consoleport=2400
12 SET jmxport=1088
13 SET jvmMaxMemory=
14 SET extraJVMOpts=
15 SET consoleOpts=-console -consoleLog
16 SET PID=
17 SET JAVA_H=%JAVA_HOME%\bin\jps.exe
18
19 :LOOP
20 IF "%~1" NEQ "" (
21     SET CARG=%~1
22     IF "!CARG!"=="-debug" (
23        SET debugEnabled=true
24        SHIFT
25        GOTO :LOOP
26     )
27     IF "!CARG!"=="-debugsuspend" (
28        SET debugEnabled=true
29        SET debugSuspended=true
30        SHIFT
31        GOTO :LOOP
32     )
33     IF "!CARG!"=="-debugport" (
34        SET debugEnabled=true
35        SET debugport=%~2
36        SHIFT & SHIFT
37        GOTO :LOOP
38     )
39     IF "!CARG!"=="-jmx" (
40        SET jmxEnabled=true
41        SHIFT
42        GOTO :LOOP
43     )
44     IF "!CARG!"=="-jmxport" (
45        SET jmxEnabled=true
46        SET jmxport=%~2
47        SHIFT & SHIFT
48        GOTO :LOOP
49     )
50     IF "!CARG!"=="-start" (
51        SET startEnabled=true
52        SHIFT
53        GOTO :LOOP
54     )
55     IF "!CARG!"=="-consoleport" (
56        SET consoleport=%~2
57        SHIFT & SHIFT
58        GOTO :LOOP
59     )
60     IF "!CARG!"=="-console" (
61        SHIFT
62        GOTO :LOOP
63     )
64     IF "!CARG!"=="-status" (
65        for /F "TOKENS=1" %%G in ('""!JAVA_H!" -lvV ^| find /I "opendaylight""') do (
66            set PID=%%G
67        )
68        if "!PID!" NEQ "" (
69            ECHO Controller is running with PID !PID!
70        ) else (
71            ECHO Controller is not running.
72        )
73        GOTO :EOF
74     )
75     IF "!CARG!"=="-stop" (
76        for /F "TOKENS=1" %%G in ('""!JAVA_H!" -lvV ^| find /I "opendaylight""') do (
77            set PID=%%G
78        )
79        if "!PID!" NEQ "" (
80            ECHO Stopping controller PID !PID!
81            TASKKILL /F /PID !PID!
82        ) else (
83            ECHO Controller is not running.
84        )
85        GOTO :EOF
86     )
87     IF "!CARG:~0,4!"=="-Xmx" (
88        SET jvmMaxMemory=!CARG!
89        SHIFT
90        GOTO :LOOP
91     )
92     IF "!CARG:~0,2!"=="-D" (
93        SET extraJVMOpts=!extraJVMOpts! !CARG!
94        SHIFT
95        GOTO :LOOP
96     )
97     IF "!CARG:~0,2!"=="-X" (
98        SET extraJVMOpts=!extraJVMOpts! !CARG!
99        SHIFT
100        GOTO :LOOP
101     )
102     IF "!CARG!"=="-help" (
103         SHIFT
104         SET CARG=%2
105         IF "!CARG!" NEQ "" (
106              CALL:!CARG!
107         ) ELSE (
108               CALL:helper
109          )
110         GOTO :EOF
111     )
112
113     ECHO "Unknown option: !CARG!"
114     EXIT /B 1
115 )
116
117 IF "%debugEnabled%" NEQ "" (
118     REM ECHO "DEBUG enabled"
119     SET extraJVMOpts=!extraJVMOpts! -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=%debugport%
120 )
121
122 IF "%debugSuspended%" NEQ "" (
123     REM ECHO "DEBUG enabled suspended"
124     SET extraJVMOpts=!extraJVMOpts! -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%debugport%
125 )
126
127 IF "%jvmMaxMemory%"=="" (
128     SET jvmMaxMemory=-Xmx1G
129     ECHO Setting maximum memory to 1G.
130 )
131
132 SET extraJVMOpts=!extraJVMOpts!  %jvmMaxMemory%
133
134 IF "%jmxEnabled%" NEQ "" (
135     REM ECHO "JMX enabled "
136     SET extraJVMOpts=!extraJVMOpts! -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=%jmxport% -Dcom.sun.management.jmxremote
137 )
138 IF "%startEnabled%" NEQ "" (
139     REM ECHO "START enabled "
140     SET consoleOpts=-console %consoleport% -consoleLog
141 )
142
143 REM       Check if controller is already running
144 for /F "TOKENS=1" %%G in ('""!JAVA_H!" -lvV ^| find /I "opendaylight""') do (
145     SET PID=%%G
146 )
147 if "!PID!" NEQ "" (
148    ECHO Controller is already running with PID !PID!
149    EXIT /B 1
150 )
151
152
153 REM       Now set the classpath:
154 SET cp="%basedir%lib\org.eclipse.osgi-3.8.1.v20120830-144521.jar;%basedir%lib\org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar;%basedir%lib\org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar"
155
156 REM       Now set framework classpath
157 SET fwcp="file:\%basedir%lib\org.eclipse.osgi-3.8.1.v20120830-144521.jar,file:\%basedir%lib\org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar,file:\%basedir%lib\org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar"
158
159 SET RUN_CMD="%JAVA_HOME%\bin\java.exe" -Dopendaylight.controller !extraJVMOpts! -Djava.io.tmpdir="%basedir%work\tmp" -Djava.awt.headless=true -Dosgi.install.area=%basedir% -Dosgi.configuration.area="%basedir%configuration" -Dosgi.frameworkClassPath=%fwcp% -Dosgi.framework="file:\%basedir%lib\org.eclipse.osgi-3.8.1.v20120830-144521.jar" -classpath %cp% org.eclipse.equinox.launcher.Main %consoleOpts%
160
161 ECHO !RUN_CMD!
162
163 if "%startEnabled%" NEQ "" (
164     START /B cmd /C CALL !RUN_CMD! > %basedir%\logs\controller.out 2>&1
165     ECHO Running controller in the background.
166     EXIT /B 1
167 ) else (
168     !RUN_CMD!
169     EXIT /B %ERRORLEVEL%
170 )
171
172 :helper
173 echo. For more information on a specific command, type -help command-name.
174 echo.
175 echo   jmx              ^[-jmx^]
176 echo   jmxport          ^[-jmxport ^<num^>^] - DEFAULT is 1088
177 echo   debug            ^[-debug^]
178 echo   debugsuspend     ^[-debugsuspend^]
179 echo   debugport        ^[-debugport ^<num^>^] - DEFAULT is 8000
180 echo   start            ^[-start ^[^<console port^>^]^] - DEFAULT port is 2400
181 echo   stop             ^[-stop^]
182 echo   status           ^[-status^]
183 echo   console          ^[-console^]
184 echo   agentpath        ^[-agentpath:^<path to lib^>^]
185 exit/B 1
186
187 :debugsuspend
188 ECHO.
189 ECHO. debugsuspend     ^[-debugsuspend^]
190 ECHO.
191 ECHO. This command sets suspend on true in runjdwp in extra JVM options. If its true, VMStartEvent has a suspendPolicy of SUSPEND_ALL. If its false, VMStartEvent has a suspendPolicy of SUSPEND_NONE.
192 ECHO.
193 EXIT /B 1
194
195 :debugport
196 ECHO.
197 ECHO. debugport        ^[-debugport ^<num^>^] - DEFAULT is 8000
198 ECHO.
199 ECHO. Set address for settings in runjdwp in extra JVM options.
200 ECHO. The address is transport address for the connection.
201 ECHO. The address has to be in the range ^[1024,65535^]. If the option was not call, port will be set to default value.
202 ECHO.
203 EXIT /B 1
204
205 :jmxport
206 ECHO.
207 ECHO. jmxport          ^[-jmxport ^<num^>^] - DEFAULT is 1088
208 ECHO.
209 ECHO.    Set jmx port for com.sun.management.jmxremote.port in JMX support. Port has to be in the range ^[1024,65535^]. If this option was not call, port will be set to default value.
210 ECHO.
211 EXIT /B 1
212
213 :debug
214 ECHO.
215 ECHO. debug            [-debug]
216 ECHO.
217 ECHO. Run ODL controller with -Xdebug and -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=^$^{debugport^}
218 ECHO.
219 ECHO.    -Xdebug enables debugging capabilities in the JVM which are used by the Java Virtual Machine Tools Interface (JVMTI). JVMTI is a low-level debugging interface used by debuggers and profiling tools.
220 ECHO.
221 ECHO.    -Xrunjdwp option loads the JPDA reference implementation of JDWP. This library resides in the target VM and uses JVMDI and JNI to interact with it. It uses a transport and the JDWP protocol to communicate with a separate debugger application.
222 ECHO.
223 ECHO. settings for -Xrunjdwp:
224 ECHO.            transport -  name of the transport to use in connecting to debugger application
225 ECHO.            server    -  if 'y', listen for a debugger application to attach; otherwise, attach to the debugger application at the specified address
226 ECHO.                      -  if 'y' and no address is specified, choose a transport address at which to listen for a debugger application, and print the address to the standard output stream
227 ECHO.            suspend   -  if 'y', VMStartEvent has a suspend Policy of SUSPEND_ALL
228 ECHO.                      -  if 'n', VMStartEvent has a suspend policy of SUSPEND_NONE
229 ECHO.            address   -  transport address for the connection
230 ECHO.                      -  if server=n, attempt to attach to debugger application at this address
231 ECHO.          -  if server=y, listen for a connection at this address
232 ECHO.
233 EXIT /B 1
234
235 :jmx
236 ECHO.
237 ECHO. jmx              [-jmx]
238 ECHO.
239 ECHO. Add JMX support. With settings for extra JVM options: -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=^$^{jmxport^} -Dcom.sun.management.jmxremote
240 ECHO. jmxport can by set with option -jmxport ^<num^>. Default num for the option is 1088.
241 ECHO.
242 EXIT /B 1
243
244 :stop
245 ECHO.
246 ECHO. stop             ^[-stop^]
247 ECHO.
248 ECHO. If a controller is running, the command stop controller. Pid will be clean.
249 ECHO.
250 EXIT /B 1
251
252 :status
253 ECHO.
254 ECHO. status           ^[-status^]
255 ECHO.
256 ECHO. Find out whether a controller is running and print it.
257 ECHO.
258 EXIT /B 1
259
260 :start
261 ECHO.
262 ECHO. start            ^[-start ^[^<console port^>^]^]
263 ECHO.
264 ECHO.    If controller is not running, the command with argument^(for set port, where controller has start^) will start new controller on a port. The port has to be in the range ^[1024,65535^]. If this option was not call, port will be set to default value. Pid will be create.
265 EXIT /B 1
266
267 :console
268 ECHO.
269 ECHO. console          [-console]
270 ECHO.     Default option.
271 EXIT /B 1
272
273 :agentpath
274 ECHO.
275 ECHO. agentpath        ^[-agentpath:^<path to lib^>^]
276 ECHO.
277 ECHO.    Agentpath option passes path to agent to jvm in order to load native agent library, e.g. yourkit profiler agent.
278 EXIT /B 1
279
280