Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackdriver logging #68 #81

Merged
merged 112 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
e748691
Issue #68 added request context scope
gregw Nov 9, 2016
f6d1488
Issue #68 added request context scope
gregw Nov 9, 2016
2ad99b0
Issue #68 added skeleton Logging Handler
gregw Nov 9, 2016
30b3e80
Issue #68 work in progress
gregw Nov 11, 2016
7ec8ff3
Issue #68 work in progress
gregw Nov 16, 2016
1d3ca8a
working implementation using a threadlocal to stop looping
gregw Nov 17, 2016
3b5c3a7
Merge remote-tracking branch 'origin/master' into master-68
gregw Nov 17, 2016
aa81e13
Issue #68 update to latest google-cloud-java LoggingHandler
gregw Nov 17, 2016
141bae3
Merge branch 'master' into master-68
gregw Nov 30, 2016
48df809
Issue #68
gregw Nov 30, 2016
1e38c88
Issue #68 Use same labels as nginx
gregw Dec 1, 2016
f19135d
Merge branch 'master' into master-68
gregw Dec 1, 2016
4a0886e
Merge branch 'master' into master-68
gregw Dec 5, 2016
df430d6
Issue #68
gregw Dec 5, 2016
fe02767
Merge branch 'master' into master-68
gregw Dec 6, 2016
2005182
Merge branch 'master' into master-68
gregw Dec 7, 2016
3d2baec
Merge branch 'master' into master-68
gregw Dec 12, 2016
563140f
Merge branch 'master' into master-68
gregw Dec 13, 2016
3206abf
Merge branch 'master' into master-68
gregw Dec 23, 2016
9de4fc1
Issue #68
gregw Dec 23, 2016
f884043
Merge branch 'master' into master-68
meltsufin Dec 28, 2016
9ea5c97
Merge branch 'master' into master-68
meltsufin Dec 28, 2016
abc7b09
renamed traceid to traceId
gregw Dec 29, 2016
9318aa1
gcloud api not currently used
gregw Dec 29, 2016
2dc88d0
Merge branch 'master' into master-68
gregw Jan 1, 2017
d50f5ae
Tunnel traceId in parameters #68
gregw Jan 4, 2017
9e5e2db
Simplified with traceId lookup in formatter #68
gregw Jan 4, 2017
c6d8df8
Merge branch 'master' into master-68
gregw Jan 12, 2017
d5f5613
Use 8.2 beta stackdriver
gregw Jan 12, 2017
9a22c3d
Improved formatting
gregw Jan 12, 2017
4f738b7
use logger name rather than source
gregw Jan 13, 2017
34e9103
run jetty from the webapp working directory so logging configuration …
gregw Jan 13, 2017
f255ee1
Testing logging
gregw Jan 18, 2017
fc0ed8d
Merge branch 'master' into master-68
gregw Jan 23, 2017
24a9055
use released 9.4.1
gregw Jan 24, 2017
9182d7e
Issue #68
gregw Jan 24, 2017
688ed8e
Do not CD to non existant directory
gregw Jan 25, 2017
b4d7add
Merge branch 'master' into master-68
gregw Jan 26, 2017
d3e5d9d
Merge branch 'master' into master-68
gregw Jan 26, 2017
06b1a2e
improved README
gregw Jan 31, 2017
9f64c08
fixed Cloud SDK
gregw Jan 31, 2017
8fb26f2
Merge branch 'master' into master-68
meltsufin Feb 2, 2017
22e7518
Released beta of google-cloud-logging
gregw Feb 2, 2017
e7a8fcb
Merge branch 'master-68' of github.com:GoogleCloudPlatform/jetty-runt…
gregw Feb 2, 2017
4032481
Merge branch 'master' into master-68
gregw Feb 2, 2017
80ee54e
Merge branch 'master' into master-68
gregw Feb 8, 2017
4835abc
updated google-cloud API to 0.8.3-beta
gregw Feb 8, 2017
f1e55dc
added remote test to check logging
gregw Feb 10, 2017
64a0a20
Stackdriver logging testing
gregw Feb 13, 2017
cb4b5f8
Merge remote-tracking branch 'origin/master' into master-68
gregw Feb 14, 2017
cb852d3
upgrade to 0.9.2
gregw Feb 14, 2017
f3ef369
Test for zone
gregw Feb 15, 2017
72636e8
Merge branch 'master' into master-68
gregw Feb 21, 2017
912d09d
Merge branch 'master' into master-68
gregw Mar 7, 2017
eb6eddb
Merge branch 'master' into master-68
gregw Mar 9, 2017
1976930
Merge branch 'master' into master-68
gregw Mar 17, 2017
2c022d7
upgrade to 10.0 gcloud API
gregw Mar 23, 2017
cd8bdf8
enable gae module only of GAE_INSTANCE environment variable is set
gregw Mar 24, 2017
6ad4bd8
improved gae.mod documentation
gregw Mar 24, 2017
9080fc7
GCP module
gregw Mar 29, 2017
63d986d
fixed warnings
gregw Mar 29, 2017
cda775a
turn off stackdriver logging by default. Added instructions to enable.
gregw Mar 29, 2017
57613d6
Merge branch 'master' into master-gae-optional
gregw Apr 1, 2017
edc450d
Merge branch 'master' into master-68
gregw Apr 1, 2017
c1225ec
Merge branch 'master' into master-gae-optional
meltsufin Apr 5, 2017
1c4c5a9
Merge branch 'master' into master-68
meltsufin Apr 5, 2017
3a2bfa9
Updates
gregw Apr 13, 2017
1fc1244
Merge branch 'master' into master-update
gregw Apr 13, 2017
974bb28
Merge branch 'master' into master-gae-optional
gregw Apr 13, 2017
7a76e45
Merge branch 'master-update' into master-gae-optional
gregw Apr 13, 2017
c58bbaf
Use the PLATFORM env var
gregw Apr 13, 2017
c3d5f0d
Improved jetty startup
gregw Apr 13, 2017
17e3af9
Merge branch 'master' into master-gae-optional
gregw Apr 13, 2017
87cf4ae
use launcher URL
gregw Apr 13, 2017
8ea1238
Trimmed GCP specific configuration
gregw Apr 13, 2017
4766ae5
Added structure tests for jetty setup script
gregw Apr 14, 2017
aafc67a
Merge branch 'master-gae-optional' into master-68
gregw Apr 14, 2017
441a3fb
Support passing just args
gregw Apr 14, 2017
0def22a
Merge branch 'master-gae-optional' into master-68
gregw Apr 14, 2017
81014f6
fix merge
gregw Apr 14, 2017
90ca817
Merge branch 'master' into master-gae-optional
gregw Apr 14, 2017
bdad80a
Fixed test workspace paths for cloud build
Apr 14, 2017
d9a19a9
Merge branch 'master-gae-optional' into master-68
gregw Apr 14, 2017
bc4d478
Merge branch 'master' into master-68
gregw Apr 18, 2017
3240d37
review feedback
gregw Apr 18, 2017
0fc1215
working directory is the root webapp
gregw Apr 18, 2017
42ba89c
Improve handling of various types of command line.
gregw Apr 18, 2017
1c73bb6
upgrade cgloud API version to 0.13.0-beta
gregw Apr 18, 2017
21fe0cd
use package target
gregw Apr 18, 2017
151d496
tested with FINE log level
gregw Apr 19, 2017
a7e7f37
Simplify entrypoint args processing
gregw Apr 19, 2017
5a57c6d
remove debug
gregw Apr 19, 2017
d1d9a47
remove debug
gregw Apr 19, 2017
86f8154
Merge branch 'master' into master-68
gregw Apr 19, 2017
e75419d
Merge branch 'master-68' into master-68-docker-args
gregw Apr 20, 2017
3f32e54
Test that the logging dependencies are hidden from webapp classpath
gregw Apr 20, 2017
37f5bd4
update README.md with instructions to keep INFO level on io.grpc.nett…
gregw Apr 20, 2017
4754bc4
Updated to lasted openjdk-runtime
gregw Apr 22, 2017
8615410
fixed classloader test
gregw Apr 26, 2017
115759a
fixed TODO
gregw Apr 26, 2017
aa91b0b
Merge branch 'master' into master-68
gregw May 3, 2017
91a62d8
Update to jetty 9.4.5 and gcloud 1.0.1-SNAPSHOT
gregw May 3, 2017
2f7dc9c
Merge branch 'master' into master-68
gregw May 3, 2017
ac00fd1
Merge branch 'master' into master-68
gregw May 3, 2017
187cac8
Merge branch 'master-68' of github.com:GoogleCloudPlatform/jetty-runt…
gregw May 3, 2017
376481f
Merge branch 'master' into master-68
gregw May 9, 2017
4b80727
upgraded to gcloud-logging 1.0.1
gregw May 9, 2017
ae6b9ce
turn off debug
gregw May 9, 2017
21404d7
Merge branch 'master' into master-68
meltsufin May 9, 2017
de07ed9
Merge branch 'master' into master-68
gregw May 10, 2017
df47a07
updated README for latest 1.0.1 gcloud-logging
gregw May 10, 2017
bfc9e45
update classpath exclusion
gregw May 11, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 78 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,90 @@ java $JAVA_OPTS \
-jar $JETTY_HOME/start.jar \
"$@"
```
## Logging
This image is configured to use [Java Util Logging](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html)(JUL) to capture all logging from
the container and its dependencies. Applications that also use the JUL API will inherit the same logging configuration.

The configuration of the jetty container in this image can be viewed by running the image locally:
By default JUL is configured to use a [ConsoleHandler](https://docs.oracle.com/javase/8/docs/api/java/util/logging/ConsoleHandler.html) to send logs to the `stderr` of the container process. When run on as a GCP deployment, all output to `stderr` is captured and is available via the Stackdriver logging console, however more detailed and integrated logs are available if the Stackdriver logging mechanism is used directly (see below).

To alter logging configuration a new `logging.properties` file must be provided to the image that among other things can: alter log levels generated by Loggers; alter log levels accepted by handlers; add/remove/configure log handlers.


### Providing `logging.properties` via the web application
A new logging configuration file can be provided as part of the application (typically at `WEB-INF/logging.properties`)
and the Java System Property `java.util.logging.config.file` updated to reference it.

When running in a GCP environment, the system property can be set in `app.yaml`:
```yaml
env_variables:
JAVA_USER_OPTS: -Djava.util.logging.config.file=WEB-INF/logging.properties
```
docker run --rm -it launcher.gcr.io/google/jetty --list-config --list-modules

If the image is run directly, then a `-e` argument to the `docker run` command can be used to set the system property:

```bash
docker run \
-e JAVA_USER_OPTS=-Djava.util.logging.config.file=WEB-INF/logging.properties \
...
```

### Providing `logging.properties` via a custom image
If this image is being used as the base of a custom image, then the following `Dockerfile` commands can be used to add either replace the existing logging configuration file or to add a new `logging.properties` file.

The default logging configuration file is located at `/var/lib/jetty/etc/java-util-logging.properties`, which can be replaced in a custom image is built. The default configuration can be replaced with a `Dockerfile` like:

```Dockerfile
FROM gcr.io/google-appengine/jetty
ADD logging.properties /var/lib/jetty/etc/java-util-logging.properties
...
```

Alternately an entirely new location for the file can be provided and the environment amended in a `Dockerfile` like:

```Dockerfile
FROM gcr.io/google-appengine/jetty
ADD logging.properties /etc/logging.properties
ENV JAVA_USER_OPTS -Djava.util.logging.config.file=/etc/logging.properties
...
```

### Providing `logging.properties` via docker run
A `logging.properties` file may be added to an existing images using the `docker run` command if the deployment environment allows for the run arguments to be modified. The `-v` option can be used to bind a new `logging.properties` file to the running instance and the `-e` option can be used to set the system property to point to it:
```shell
docker run -it --rm \
-v /mylocaldir/logging.properties:/etc/logging.properties \
-e JAVA_USER_OPTS="-Djava.util.logging.config.file=/etc/logging.properties" \
...
```

### Enhanced Stackdriver Logging (BETA!)
When running on the Google Cloud Platform Flex environment, the Java Util Logging can be configured to send logs to Google Stackdriver Logging by providing a `logging.properties` file that configures a [LoggingHandler](http://googlecloudplatform.github.io/google-cloud-java/0.10.0/apidocs/com/google/cloud/logging/LoggingHandler.html) as follows:
```
.level=INFO
io.grpc.netty.level=INFO
sun.net.level=INFO

handlers=com.google.cloud.logging.LoggingHandler
com.google.cloud.logging.LoggingHandler.level=FINE
com.google.cloud.logging.LoggingHandler.log=gae_app.log
com.google.cloud.logging.LoggingHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s

```
When deployed on the GCP Flex environment, an image so configured will automatically be configured with:
* a [LabelLoggingEnhancer](https://github.com/GoogleCloudPlatform/google-cloud-java/blob/v0.17.2/google-cloud-logging/src/main/java/com/google/cloud/logging/MonitoredResourceUtil.java#L224) instance, that will add labels from the monitored resource to each log entry.
* a [TraceLoggingEnhancer](https://github.com/GoogleCloudPlatform/google-cloud-java/blob/v0.17.2/google-cloud-logging/src/main/java/com/google/cloud/logging/TraceLoggingEnhancer.java) instance that will add any trace-id set to each log entry.
* the `gcp` module will be enabled that configures jetty so that the [setCurrentTraceId](https://github.com/GoogleCloudPlatform/google-cloud-java/blob/v0.17.2/google-cloud-logging/src/main/java/com/google/cloud/logging/TraceLoggingEnhancer.java#L40) method is called for any thread handling a request.

When deployed in other environments, logging enhancers can be manually configured by setting a comma separated list of class names as the
`com.google.cloud.logging.LoggingHandler.enhancers` property.

When using Stackdriver logging, it is recommended that `io.grpc` and `sun.net` logging level is kept at INFO level, as both these packages are used by Stackdriver internals and can result in verbose and/or initialisation problems.


## Extending the image
The image produced by this project may be automatically used/extended by the Cloud SDK and/or App Engine maven plugin.
Alternately it may be explicitly extended with a custom Dockerfile.
Alternately it may be explicitly extended with a custom Dockerfile.

The latest released version of this image is available at `launcher.gcr.io/google/jetty`, alternately you may
build and push your own version with the shell commands:
Expand Down
17 changes: 14 additions & 3 deletions jetty9-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging</artifactId>
<version>${gcloud.api.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -96,7 +107,7 @@
</execution>
<execution>
<id>gcp-jars</id>
<phase>pre-integration-test</phase>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
Expand All @@ -118,7 +129,7 @@
<executions>
<execution>
<id>add-jetty-modules</id>
<phase>pre-integration-test</phase>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
Expand All @@ -139,7 +150,7 @@
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>pre-integration-test</phase>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
Expand Down
7 changes: 0 additions & 7 deletions jetty9-base/src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,5 @@
<exclude>**/META-INF/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>jetty-base/lib/gcp</outputDirectory>
<includes>
<include>${artifactId}-${version}.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.runtimes.jetty9;

import com.google.cloud.logging.TraceLoggingEnhancer;

import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandler.Context;
import org.eclipse.jetty.server.handler.ContextHandler.ContextScopeListener;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
* A Jetty {@link ContextScopeListener} that is called whenever
* a container managed thread enters or exits the scope of a context and/or request.
* Used to maintain {@link ThreadLocal} references to the current request and
* Google traceID, primarily for logging.
* @see TracingLogHandler
*/
public class RequestContextScope implements ContextHandler.ContextScopeListener {
static final Logger logger = Logger.getLogger(RequestContextScope.class.getName());

private static final String X_CLOUD_TRACE = "x-cloud-trace-context";
private static final ThreadLocal<Integer> contextDepth = new ThreadLocal<>();

@Override
public void enterScope(Context context, Request request, Object reason) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("enterScope " + context);
}
if (request != null) {
Integer depth = contextDepth.get();
if (depth == null || depth.intValue() == 0) {
depth = 1;
String traceId = (String) request.getAttribute(X_CLOUD_TRACE);
if (traceId == null) {
traceId = request.getHeader(X_CLOUD_TRACE);
if (traceId != null) {
int slash = traceId.indexOf('/');
if (slash >= 0) {
traceId = traceId.substring(0, slash);
}
request.setAttribute(X_CLOUD_TRACE, traceId);
TraceLoggingEnhancer.setCurrentTraceId(traceId);
}
} else {
depth = depth + 1;
}
contextDepth.set(depth);
}
}
}

@Override
public void exitScope(Context context, Request request) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("exitScope " + context);
}
Integer depth = contextDepth.get();
if (depth != null) {
if (depth > 1) {
contextDepth.set(depth - 1);
} else {
contextDepth.remove();
TraceLoggingEnhancer.setCurrentTraceId(null);
}
}
}
}
4 changes: 2 additions & 2 deletions jetty9-base/src/main/jetty-base/config-scripts/jetty.commands
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--create-startd

--add-to-start=server,webapp,http,deploy,jsp,jstl,resources
--approve-all-licenses
--add-to-start=server,webapp,http,deploy,jsp,jstl,resources,logging-jul,jcl-slf4j

10 changes: 7 additions & 3 deletions jetty9-base/src/main/jetty-base/etc/gcp-web.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">

<!-- Allow start exceptions to propagate -->
<Set name="throwUnavailableOnStartupException">true</Set>

<!-- Add listener to capture request context to be used by logging -->
<Call name="addEventListener">
<Arg><New class="com.google.cloud.runtimes.jetty9.RequestContextScope"/></Arg>
</Call>

<!-- Protect app.yaml -->
<Get id="protected" name="ProtectedTargets"/>
<Set name="ProtectedTargets">
Expand All @@ -16,6 +21,5 @@
</Set>

<Set name="overrideDescriptor"><Property name="jetty.base"/>/etc/gcp-override-web.xml</Set>

</Configure>

14 changes: 14 additions & 0 deletions jetty9-base/src/main/jetty-base/etc/java-util-logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.level=INFO

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s%n

## To use Stackdriver Logging replace the configuration above with the configuration below:
# handlers=com.google.cloud.logging.LoggingHandler
# com.google.cloud.logging.LoggingHandler.level=FINE
# com.google.cloud.logging.LoggingHandler.log=gae_app.log
# com.google.cloud.logging.LoggingHandler.resourceType=gae_app
# com.google.cloud.logging.LoggingHandler.enhancers=com.google.cloud.logging.GaeFlexLoggingEnhancer
# com.google.cloud.logging.LoggingHandler.formatter=java.util.logging.SimpleFormatter
# java.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s
3 changes: 3 additions & 0 deletions jetty9-base/src/main/jetty-base/modules/gcp.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ jetty.httpConfig.sendServerVersion?=true

# Don't send date header
jetty.httpConfig.sendDateHeader?=false

# Hide the gcloud libraries from deployed webapps
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/gcp/
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.runtimes.jetty9;

import java.io.IOException;
import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@SuppressWarnings("serial")
@WebServlet(urlPatterns = {"/", "/test/*"}, name = "TestServlet")
public class TestServlet extends HttpServlet {
static final Logger log = Logger.getLogger(TestServlet.class.getName());

@PostConstruct
private void myPostConstructMethod() {
log.info("preconstructed");
}

@Override
public void init() throws ServletException {
log.info("init info");
getServletContext().log("init ServletContext.log");
}

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
log.info("doGet info");
getServletContext().log("doGet ServletContext.log");

if (request.getParameter("ex") != null) {
try {
throw (Throwable) Class.forName(request.getParameter("ex")).newInstance();
} catch (ServletException | IOException ex) {
throw ex;
} catch (Throwable th) {
throw new ServletException(th);
}
}
response.getWriter().println("Log Test");
}
}
28 changes: 19 additions & 9 deletions jetty9/src/main/docker/50-jetty.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ if [ ! -e "$ROOT_DIR" -a -d /app ]; then
ln -s /app "$ROOT_DIR"
fi

# move command line args to $JETTY_ARGS
export JETTY_ARGS="${@/$1/}"
set - "$1"

# Check for start.jar
if [ "$(echo $JETTY_ARGS | egrep start.jar | wc -l )" = "0" ]; then
JETTY_ARGS="-Djetty.base=${JETTY_BASE} -jar ${JETTY_HOME}/start.jar $JETTY_ARGS"
# If a webapp root directory exist, use it as the work directory
if [ -d "$ROOT_DIR" ]; then
cd "$ROOT_DIR"
fi

# Calculate the Jetty args
export JETTY_ARGS

# Add any Jetty properties to the JETTY_ARGS
if [ "$JETTY_PROPERTIES" ]; then
JETTY_ARGS="$JETTY_ARGS ${JETTY_PROPERTIES//,/ }"
Expand All @@ -52,7 +51,18 @@ if [ "$PLATFORM" = "gae" ]; then
JETTY_ARGS="$JETTY_ARGS --module=gcp"
fi

# add the JETTY_ARGS to the JAVA_OPTS
export JAVA_OPTS="$JAVA_OPTS $JETTY_ARGS"
# If command line is running java, then assume it is jetty and mix in JETTY_ARGS
if [ "$1" = "java" ]; then
# Check for jetty start.jar and prepend if missing
if [ "$(echo $@ | egrep start.jar | wc -l )" = "0" ]; then
shift
set -- java -Djetty.base=${JETTY_BASE} -jar ${JETTY_HOME}/start.jar $@
fi

# Append JETTY_ARGS
if [ -n "$JETTY_ARGS" ]; then
shift
set -- java $@ $JETTY_ARGS
fi
fi

Loading