Fixed netconf monitoring.
[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 extraJVMOpts=
14 SET consoleOpts=-console -consoleLog
15 SET PID=
16
17 :LOOP
18 IF "%~1" NEQ "" (
19     SET CARG=%~1
20     IF "!CARG!"=="-debug" (
21        SET debugEnabled=true
22        SHIFT
23        GOTO :LOOP
24     )
25     IF "!CARG!"=="-debugsuspend" (
26        SET debugEnabled=true
27        SET debugSuspended=true
28        SHIFT
29        GOTO :LOOP
30     )
31     IF "!CARG!"=="-debugport" (
32        SET debugEnabled=true
33        SET debugport=%~2
34        SHIFT & SHIFT
35        GOTO :LOOP
36     )
37     IF "!CARG!"=="-jmx" (
38        SET jmxEnabled=true
39        SHIFT
40        GOTO :LOOP
41     )
42     IF "!CARG!"=="-jmxport" (
43        SET jmxEnabled=true
44        SET jmxport=%~2
45        SHIFT & SHIFT
46        GOTO :LOOP
47     )
48     IF "!CARG!"=="-start" (
49        SET startEnabled=true
50        SHIFT
51        GOTO :LOOP
52     )
53     IF "!CARG!"=="-consoleport" (
54        SET consoleport=%~2
55        SHIFT & SHIFT
56        GOTO :LOOP
57     )
58     IF "!CARG!"=="-console" (
59        SHIFT
60        GOTO :LOOP
61     )
62     IF "!CARG!"=="-status" (
63        for /F "TOKENS=1" %%G in ('%JAVA_HOME%\bin\jps.exe -lvV ^| find /I "opendaylight"') do (
64            set PID=%%G
65        )
66        if "!PID!" NEQ "" (
67            ECHO Controller is running with PID !PID!
68        ) else (
69            ECHO Controller is not running.
70        )
71        GOTO :EOF
72     )
73     IF "!CARG!"=="-stop" (
74        for /F "TOKENS=1" %%G in ('%JAVA_HOME%\bin\jps.exe -lvV ^| find /I "opendaylight"') do (
75            set PID=%%G
76        )
77        if "!PID!" NEQ "" (
78            ECHO Stopping controller PID !PID!
79            TASKKILL /F /PID !PID!
80        ) else (
81            ECHO Controller is not running.
82        )
83        GOTO :EOF
84     )
85     IF "!CARG:~0,2!"=="-D" (
86        SET extraJVMOpts=%extraJVMOpts% !CARG!
87        SHIFT
88        GOTO :LOOP
89     )
90     IF "!CARG:~0,2!"=="-X" (
91        SET extraJVMOpts=%extraJVMOpts% !CARG!
92        SHIFT
93        GOTO :LOOP
94     )
95     IF "!CARG!"=="-help" (
96         ECHO "Usage: %0 [-jmx] [-jmxport <num>] [-debug] [-debugsuspend] [-debugport <num>] [-start] [-consoleport <num>]] [-stop] [-status] [-console] [-help] [<other args will automatically be used for the JVM>]"
97         ECHO Note: Enclose any JVM or System properties within double quotes.
98         GOTO :EOF
99     )
100
101     ECHO "Unknown option: !CARG!"
102     EXIT /B 1
103 )
104
105 IF "%debugEnabled%" NEQ "" (
106     REM ECHO "DEBUG enabled"
107     SET extraJVMOpts=%extraJVMOpts% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=%debugport%
108 )
109 IF "%debugSuspended%" NEQ "" (
110     REM ECHO "DEBUG enabled suspended"
111     SET extraJVMOpts=%extraJVMOpts% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%debugport%
112 )
113 IF "%jmxEnabled%" NEQ "" (
114     REM ECHO "JMX enabled "
115     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
116 )
117 IF "%startEnabled%" NEQ "" (
118     REM ECHO "START enabled "
119     SET consoleOpts=-console %consoleport% -consoleLog
120 )
121
122 REM       Check if controller is already running
123 for /F "TOKENS=1" %%G in ('%JAVA_HOME%\bin\jps.exe -lvV ^| find /I "opendaylight"') do (
124     SET PID=%%G
125 )
126 if "!PID!" NEQ "" (
127    ECHO Controller is already running with PID !PID!
128    EXIT /B 1
129 )
130
131
132 REM       Now set the classpath:
133 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"
134
135 REM       Now set framework classpath
136 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"
137
138 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%
139
140 ECHO %RUN_CMD%
141
142 if "%startEnabled%" NEQ "" (
143     START /B cmd /C CALL %RUN_CMD%
144     ECHO Running controller in the background.
145 ) else (
146     %RUN_CMD%
147     EXIT /B %ERRORLEVEL%
148 )
149
150