source: trunk/kauri.bat @ 1962

Revision 1745, 3.4 KB checked in by bruno, 19 months ago (diff)

Fix log4j.properties loading. My previous change related to this (r1702) was based upon the misunderstanding that log4j loads the log4j.properties file from the current working directory. It doesn't, it loads it because the current working directory is by accident added to the classpath when KAURI_CLI_CLASSPATH is empty. While the net result is the same, this behavior is specific to using Kauri's startup scripts (and to $KAURI_CLI_CLASSPATH being empty), and when launching RuntimeCliLauncher? in some other way (think of: custom script, java service wrapper, from an IDE or a profiler, ...), this will result in confusing behavior.
Also modified the scripts to no longer add the working dir to the classpath when $KAURI_CLI_CLASSPATH is empty. Usually we will configure log4j before it auto-configures itself, so this will not be an issue, but seems safer anyhow. I did not test the changes done to the windows script or to the kauri.sh for use in the binary dist.

Line 
1@echo off
2
3rem
4rem Kauri Runtime startup script for use during Kauri development
5rem  meaning: there is no KAURI_HOME, Kauri artifacts are in dev's local Maven repo
6rem
7
8rem You can use the following environment variables to customize the startup
9rem
10rem KAURI_CLI_CLASSPATH
11rem    additional entries to be added to the classpath
12rem
13rem KAURI_JAVA_ARGS
14rem    additional options to be passed to the java executable
15rem
16rem KAURI_DEBUG_ARGS
17rem    can be used to define alternative Java debug arguments
18rem
19rem KAURI_DEBUG_SUSPEND_ARGS
20rem    can be used to define alternative Java debug arguments for suspended mode
21
22
23rem
24rem Disclaimer: this script is based on stuff from Apache Cocoon's 'cocoon.bat' script
25rem
26
27:: ----- Verify and Set Required Environment Variables -------------------------
28
29if not "%JAVA_HOME%"=="" goto gotJavaHome
30echo JAVA_HOME not set!
31goto end
32:gotJavaHome
33
34:: ----- Find out home dir of this script --------------------------------------
35
36if not "%KAURI_SRC_HOME%"=="" goto gotKauriSrcHome
37rem %~dp0 is expanded pathname of the current script under NT
38set KAURI_SRC_HOME=%~dp0
39:gotKauriSrcHome
40
41:: ----- Check System Properties -----------------------------------------------
42
43set LAUNCHER_JAR=%KAURI_SRC_HOME%\core\kauri-runtime-launcher\target\kauri-runtime-launcher.jar
44
45IF EXIST %LAUNCHER_JAR% goto launcherJarExists
46echo Launcher jar not found at %LAUNCHER_JAR%
47echo Please build Kauri first using 'mvn install'
48goto end
49
50:launcherJarExists
51
52set CLASSPATH=%LAUNCHER_JAR%
53
54rem Only add KAURI_CLI_CLASSPATH when it is not empty, to avoid adding the working dir to
55rem the classpath by accident.
56if "%KAURI_CLI_CLASSPATH%"=="" goto noExtraClassPath
57set CLASSPATH=%CLASSPATH%;%KAURI_CLI_CLASSPATH%
58:noExtraClassPath
59
60if not "%KAURI_DEBUG_ARGS%"=="" goto gotKauriDebugArgs
61set KAURI_DEBUG_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
62:gotKauriDebugArgs
63
64if not "%KAURI_DEBUG_SUSPEND_ARGS%"=="" goto gotKauriDebugSuspendArgs
65set KAURI_DEBUG_SUSPEND_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
66:gotKauriDebugSuspendArgs
67
68:: ----- Build params to forward to Kauri --------------------------------------
69set action=%1
70
71set param=
72shift
73:cliLoop
74if "%1"=="" goto cliLoopEnd
75if not "%1"=="" set param=%param% %1
76shift
77goto cliLoop
78
79:cliLoopEnd
80
81:: ----- Check action ----------------------------------------------------------
82
83if ""%action%"" == """" goto doRun
84if ""%action%"" == ""run"" goto doRun
85if ""%action%"" == ""debug"" goto doDebug
86if ""%action%"" == ""debug-suspend"" goto doDebugSuspend
87
88echo Usage: kauri (action)
89echo actions:
90echo   run             Run the Kauri Runtime (default)
91echo   debug           Run the Kauri Runtime, listed to debugger on port 5005
92echo   debug-suspend   Run the Kauri Runtime, suspend for debugger on port 5005
93echo:
94echo To see help options for Kauri, use kauri run -h
95echo To pass options to Kauri, use kauri run {options}
96goto end
97
98:doRun
99
100"%JAVA_HOME%/bin/java" %KAURI_JAVA_ARGS% org.kauriproject.launcher.RuntimeCliLauncher %param%
101goto end
102
103:doDebug
104
105"%JAVA_HOME%/bin/java" %KAURI_JAVA_ARGS% %KAURI_DEBUG_ARGS% org.kauriproject.launcher.RuntimeCliLauncher %param%
106goto end
107
108:doDebugSuspend
109echo:
110echo Don't forget: you'll need to connect with a debugger for Kauri to start
111echo:
112"%JAVA_HOME%/bin/java" %KAURI_JAVA_ARGS% %KAURI_DEBUG_SUSPEND_ARGS% org.kauriproject.launcher.RuntimeCliLauncher %param%
113goto end
114
115:end
116if "%_EXIT_ERRORLEVEL%"=="true" exit %ERRORLEVEL%
Note: See TracBrowser for help on using the repository browser.