source: trunk/kauri.sh @ 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.

  • Property svn:executable set to *
Line 
1#! /bin/sh
2
3#
4# Kauri Runtime startup script for use during Kauri development
5#  meaning: there is no KAURI_HOME, Kauri artifacts are in dev's local Maven repo
6#
7
8# You can use the following environment variables to customize the startup
9#
10# KAURI_CLI_CLASSPATH
11#    additional entries to be added to the classpath
12#
13# KAURI_JAVA_ARGS
14#    additional options to be passed to the java executable
15#
16# KAURI_DEBUG_ARGS
17#    can be used to define alternative Java debug arguments
18#
19# KAURI_DEBUG_SUSPEND_ARGS
20#    can be used to define alternative Java debug arguments for suspended mode
21#
22
23#
24# Disclaimer: this script is based on stuff from Apache Cocoon's 'cocoon.sh' script
25#
26
27usage()
28{
29    echo "Usage: $0 (action)"
30    echo "actions:"
31    echo "  run               Run the Kauri Runtime (default)"
32    echo "  debug             Run the Kauri Runtime with debug port 5005"
33    echo "  debug-suspend     Run the Kauri Runtime, suspend for debugger to connect on port 5005"
34    echo ""
35    echo "To see help options for Kauri, use $0 run -h"
36    echo ""
37    exit 1
38}
39
40
41# ----- Handle action parameter ------------------------------------------------
42DEFAULT_ACTION="run"
43ACTION="$1"
44if [ -n "$ACTION" ]
45then
46  shift
47else
48  ACTION=$DEFAULT_ACTION
49  echo "$0: executing default action '$ACTION', use -h to see other actions"
50fi
51ARGS="$*"
52
53
54
55# ----- Find out home dir of this script ---------------------------------------
56
57#
58# Disclaimer: this is based on things seen in Ant's startup script
59#
60
61## resolve links - $0 may be a link to Kauri's home
62PRG="$0"
63progname=`basename "$0"`
64
65# need this for relative symlinks
66while [ -h "$PRG" ] ; do
67ls=`ls -ld "$PRG"`
68link=`expr "$ls" : '.*-> \(.*\)$'`
69if expr "$link" : '/.*' > /dev/null; then
70PRG="$link"
71else
72PRG=`dirname "$PRG"`"/$link"
73fi
74done
75
76KAURI_SRC_HOME=`dirname "$PRG"`
77
78# make it fully qualified
79KAURI_SRC_HOME=`cd "$KAURI_SRC_HOME" && pwd`
80
81
82# ----- Verify and Set Required Environment Variables -------------------------
83if [ -z "$JAVA_HOME" ] ; then
84  echo "JAVA_HOME not set!"
85  exit 1
86fi
87
88LAUNCHER_JAR=$KAURI_SRC_HOME/core/kauri-runtime-launcher/target/kauri-runtime-launcher.jar
89
90[ ! -r "$LAUNCHER_JAR" ] \
91  && echo "Launcher jar not found at $LAUNCHER_JAR" \
92  && echo "Please build Kauri first using 'mvn install'" \
93  && exit 1
94
95CLASSPATH=$LAUNCHER_JAR
96
97# Only add KAURI_CLI_CLASSPATH when it is not empty, to avoid adding the working dir to
98# the classpath by accident.
99if [ ! -z "$KAURI_CLI_CLASSPATH" ] ; then
100  CLASSPATH=$CLASSPATH:$KAURI_CLI_CLASSPATH
101fi
102
103export CLASSPATH
104
105if [ "$KAURI_DEBUG_ARGS" = "" ] ; then
106  KAURI_DEBUG_ARGS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
107fi
108
109if [ "$KAURI_DEBUG_SUSPEND_ARGS" = "" ] ; then
110  KAURI_DEBUG_SUSPEND_ARGS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
111fi
112
113# ----- Do the action ----------------------------------------------------------
114
115case "$ACTION" in
116  run)
117        "$JAVA_HOME/bin/java" -Djava.awt.headless=true $KAURI_JAVA_ARGS org.kauriproject.launcher.RuntimeCliLauncher $@
118        ;;
119
120  debug)
121        "$JAVA_HOME/bin/java" -Djava.awt.headless=true $KAURI_JAVA_ARGS $KAURI_DEBUG_ARGS org.kauriproject.launcher.RuntimeCliLauncher $@
122        ;;
123
124  debug-suspend)
125        echo "Don't forget: you'll need to connect with a debugger for Kauri to start"
126        "$JAVA_HOME/bin/java" -Djava.awt.headless=true $KAURI_JAVA_ARGS $KAURI_DEBUG_SUSPEND_ARGS org.kauriproject.launcher.RuntimeCliLauncher $@
127        ;;
128
129  *)
130        usage
131        ;;
132esac
133
134exit 0
Note: See TracBrowser for help on using the repository browser.