Skip to content

Commit c817c92

Browse files
authored
Merge pull request GoogleCloudPlatform#338 from jetty-project/gcloud-jetty-runtime-4
Updated async-rest demo to latest Flex
2 parents 636ede9 + e6cd934 commit c817c92

File tree

8 files changed

+74
-80
lines changed

8 files changed

+74
-80
lines changed

managed_vms/async-rest/README.md

+6-15
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ First, complete the following steps:
1616
- Install the Cloud SDK `app-engine-java` component.
1717
- Authenticate wth the gcloud SDK: gcloud auth login.
1818
- Install [Maven](http://maven.apache.org/download.cgi) if you haven't already.
19-
2019

2120

2221
## Providing your Google Places API key ##
2322

24-
You will need to edit the pom.xml file and replace YOUR_PLACES_APP_KEY with the value of your key:
23+
To run locally, you need to edit the pom.xml file and replace YOUR_PLACES_APP_KEY with the value of your key:
2524

2625
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>
2726

28-
You then have several options of how to run it:
27+
To deploy to gcloud, you need to edit the src/main/appengine/app.yaml file and replace YOUR_PLACES_APP_KEY with the value of your key:
28+
29+
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY'
2930

31+
3032
## Running locally without the AppEngine environment ##
3133

3234
The application does not use any AppEngine specific services, so you can run it simply on your local machine by doing:
@@ -36,22 +38,11 @@ The application does not use any AppEngine specific services, so you can run it
3638
Go to http://localhost:8080 to see the webapp.
3739

3840

39-
## Running locally using Docker ##
40-
41-
The project also can build a docker image based on the jetty9 image for [Google Container Engine](https://cloud.google.com/container-engine/).
42-
First uncomment the maven plugin section for docker-maven-plugin in the pom.xml.
43-
The WAR file is installed in the webapps directory and the resulting image can be run locally with:
44-
45-
docker run --rm -it -p 8080:8080 jetty9-async-rest --exec -Dcom.google.appengine.demos.asyncrest.appKey=YOUR_PLACES_APP_KEY
46-
47-
Where you replace YOUR_PLACES_APP_KEY with the key you obtained in the initial setup.
48-
49-
5041
## Deploying to the cloud as an AppEngine ManagedVM ##
5142

5243
To automatically stage and deploy the webapp to your project in the cloud do:
5344

54-
mvn gcloud:deploy
45+
mvn appengine:deploy
5546

5647
See here for more information on the [GCloud Maven Plugin](https://github.com/GoogleCloudPlatform/gcloud-maven-plugin).
5748

managed_vms/async-rest/pom.xml

+9-53
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
</parent>
3030

3131
<properties>
32-
<docker.label.prefix>async-</docker.label.prefix>
33-
<jetty.version>9.3.7.v20160115</jetty.version>
32+
<appengine.maven.plugin>0.1.2</appengine.maven.plugin>
33+
<jetty.version>9.3.8.v20160314</jetty.version>
3434
<maven.compiler.target>1.8</maven.compiler.target>
3535
<maven.compiler.source>1.8</maven.compiler.source>
3636
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>
@@ -50,15 +50,13 @@
5050
</systemProperties>
5151
</configuration>
5252
</plugin>
53-
<plugin>
54-
<groupId>com.google.appengine</groupId>
55-
<artifactId>gcloud-maven-plugin</artifactId>
56-
<version>2.0.9.106.v20160420</version>
57-
<configuration>
58-
<verbosity>debug</verbosity>
59-
<log_level>debug</log_level>
60-
<non_docker_mode>false</non_docker_mode>
61-
<docker_build>remote</docker_build>
53+
<plugin>
54+
<groupId>com.google.cloud.tools</groupId>
55+
<artifactId>appengine-maven-plugin</artifactId>
56+
<version>${appengine.maven.plugin}</version>
57+
<configuration>
58+
<deploy.promote>true</deploy.promote>
59+
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
6260
</configuration>
6361
</plugin>
6462
<plugin>
@@ -77,48 +75,6 @@
7775
</webResources>
7876
</configuration>
7977
</plugin>
80-
<!--plugin>
81-
<groupId>com.spotify</groupId>
82-
<artifactId>docker-maven-plugin</artifactId>
83-
<version>0.4.0</version>
84-
<executions>
85-
<execution>
86-
<id>build-docker-image</id>
87-
<phase>package</phase>
88-
<goals>
89-
<goal>build</goal>
90-
</goals>
91-
<configuration>
92-
<baseImage>jetty9:${docker.label.prefix}${jetty.version}</baseImage>
93-
<forceTags>true</forceTags>
94-
<imageName>jetty9-async-rest</imageName>
95-
<imageTags>
96-
<imageTag>${docker.label.prefix}${project.version}</imageTag>
97-
</imageTags>
98-
<resources>
99-
<resource>
100-
<targetPath>/var/lib/jetty/webapps</targetPath>
101-
<directory>${project.build.directory}</directory>
102-
<include>${project.build.finalName}.war</include>
103-
</resource>
104-
</resources>
105-
</configuration>
106-
</execution>
107-
<execution>
108-
<id>clean-docker</id>
109-
<phase>clean</phase>
110-
<goals>
111-
<goal>removeImage</goal>
112-
</goals>
113-
<configuration>
114-
<imageName>jetty9-async-rest</imageName>
115-
<imageTags>
116-
<imageTag>${docker.label.prefix}${project.version}</imageTag>
117-
</imageTags>
118-
</configuration>
119-
</execution>
120-
</executions>
121-
</plugin-->
12278
</plugins>
12379
</build>
12480
<dependencies>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# [START appyaml]
15+
runtime: custom
16+
vm: true
17+
18+
handlers:
19+
- url: /.*
20+
script: this field is required, but ignored
21+
secure: always
22+
23+
24+
env_variables:
25+
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY'
26+
27+
# [END appyaml]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM gcr.io/google_appengine/jetty9
2+
#FROM gcr.io/YOUR_PROJECT/jetty9
3+
ADD managed-vms-async-rest-1.0.0-SNAPSHOT.war $JETTY_BASE/webapps/root.war
4+
ADD jetty-logging.properties $JETTY_BASE/resources/jetty-logging.properties
5+
RUN chown jetty:jetty $JETTY_BASE/webapps/root.war $JETTY_BASE/resources/jetty-logging.properties
6+
WORKDIR $JETTY_BASE
7+
#RUN java -jar $JETTY_HOME/start.jar --approve-all-licenses --add-to-startd=jmx,stats,hawtio
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Copied to $JETTY_BASE/resources in Dockerfile
2+
3+
## Direct Jetty logging to JavaUtilLog
4+
# org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog
5+
6+
### Configure jetty root logger level for the default StdErrLog class.
7+
## Levels are OFF, DEBUG, INFO, WARN, ALL
8+
org.eclipse.jetty.LEVEL=INFO
9+
#org.eclipse.jetty.server.LEVEL=DEBUG
10+
11+
## If SOURCE is true, the filename and line number of the logging event origin are logged
12+
org.eclipse.jetty.SOURCE=false
13+
14+
## If STACKS is true, full stack traces for exceptions are logged
15+
org.eclipse.jetty.STACKS=true
16+
17+
## If LONG is true, fully qualified package names are used rather than abbreviations
18+
org.eclipse.jetty.LONG=false
19+

managed_vms/async-rest/src/main/java/com/google/appengine/demos/DumpServlet.java

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public class DumpServlet extends HttpServlet {
3131
@Override
3232
protected void doGet(HttpServletRequest request, HttpServletResponse response)
3333
throws ServletException, IOException {
34+
35+
if (Boolean.parseBoolean(request.getParameter("throw"))) {
36+
throw new ServletException("Test Exception");
37+
}
38+
3439
response.setContentType("text/html");
3540
response.setStatus(HttpServletResponse.SC_OK);
3641

managed_vms/async-rest/src/main/webapp/Dockerfile

-2
This file was deleted.

managed_vms/async-rest/src/main/webapp/WEB-INF/appengine-web.xml

-10
This file was deleted.

0 commit comments

Comments
 (0)