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

Updated async-rest demo to latest Flex #338

Merged
merged 2 commits into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 6 additions & 15 deletions managed_vms/async-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ First, complete the following steps:
- Install the Cloud SDK `app-engine-java` component.
- Authenticate wth the gcloud SDK: gcloud auth login.
- Install [Maven](http://maven.apache.org/download.cgi) if you haven't already.



## Providing your Google Places API key ##

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

<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>

You then have several options of how to run it:
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:

PLACES_APPKEY: 'YOUR_PLACES_APP_KEY'


## Running locally without the AppEngine environment ##

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


## Running locally using Docker ##

The project also can build a docker image based on the jetty9 image for [Google Container Engine](https://cloud.google.com/container-engine/).
First uncomment the maven plugin section for docker-maven-plugin in the pom.xml.
The WAR file is installed in the webapps directory and the resulting image can be run locally with:

docker run --rm -it -p 8080:8080 jetty9-async-rest --exec -Dcom.google.appengine.demos.asyncrest.appKey=YOUR_PLACES_APP_KEY

Where you replace YOUR_PLACES_APP_KEY with the key you obtained in the initial setup.


## Deploying to the cloud as an AppEngine ManagedVM ##

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

mvn gcloud:deploy
mvn appengine:deploy

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

62 changes: 9 additions & 53 deletions managed_vms/async-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
</parent>

<properties>
<docker.label.prefix>async-</docker.label.prefix>
<jetty.version>9.3.7.v20160115</jetty.version>
<appengine.maven.plugin>0.1.2</appengine.maven.plugin>
<jetty.version>9.3.8.v20160314</jetty.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>
Expand All @@ -50,15 +50,13 @@
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.106.v20160420</version>
<configuration>
<verbosity>debug</verbosity>
<log_level>debug</log_level>
<non_docker_mode>false</non_docker_mode>
<docker_build>remote</docker_build>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.plugin}</version>
<configuration>
<deploy.promote>true</deploy.promote>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
</configuration>
</plugin>
<plugin>
Expand All @@ -77,48 +75,6 @@
</webResources>
</configuration>
</plugin>
<!--plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.0</version>
<executions>
<execution>
<id>build-docker-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<baseImage>jetty9:${docker.label.prefix}${jetty.version}</baseImage>
<forceTags>true</forceTags>
<imageName>jetty9-async-rest</imageName>
<imageTags>
<imageTag>${docker.label.prefix}${project.version}</imageTag>
</imageTags>
<resources>
<resource>
<targetPath>/var/lib/jetty/webapps</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>clean-docker</id>
<phase>clean</phase>
<goals>
<goal>removeImage</goal>
</goals>
<configuration>
<imageName>jetty9-async-rest</imageName>
<imageTags>
<imageTag>${docker.label.prefix}${project.version}</imageTag>
</imageTags>
</configuration>
</execution>
</executions>
</plugin-->
</plugins>
</build>
<dependencies>
Expand Down
27 changes: 27 additions & 0 deletions managed_vms/async-rest/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2016 Google Inc. All Rights Reserved.
#
# 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.
# [START appyaml]
runtime: custom
vm: true

handlers:
- url: /.*
script: this field is required, but ignored
secure: always


env_variables:
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY'

# [END appyaml]
8 changes: 8 additions & 0 deletions managed_vms/async-rest/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM gcr.io/google_appengine/jetty9
#FROM gcr.io/YOUR_PROJECT/jetty9
ADD managed-vms-async-rest-1.0.0-SNAPSHOT.war $JETTY_BASE/webapps/root.war
ADD jetty-logging.properties $JETTY_BASE/resources/jetty-logging.properties
RUN chown jetty:jetty $JETTY_BASE/webapps/root.war $JETTY_BASE/resources/jetty-logging.properties
WORKDIR $JETTY_BASE
#RUN java -jar $JETTY_HOME/start.jar --approve-all-licenses --add-to-startd=jmx,stats,hawtio

19 changes: 19 additions & 0 deletions managed_vms/async-rest/src/main/docker/jetty-logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Copied to $JETTY_BASE/resources in Dockerfile

## Direct Jetty logging to JavaUtilLog
# org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog

### Configure jetty root logger level for the default StdErrLog class.
## Levels are OFF, DEBUG, INFO, WARN, ALL
org.eclipse.jetty.LEVEL=INFO
#org.eclipse.jetty.server.LEVEL=DEBUG

## If SOURCE is true, the filename and line number of the logging event origin are logged
org.eclipse.jetty.SOURCE=false

## If STACKS is true, full stack traces for exceptions are logged
org.eclipse.jetty.STACKS=true

## If LONG is true, fully qualified package names are used rather than abbreviations
org.eclipse.jetty.LONG=false

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class DumpServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

if (Boolean.parseBoolean(request.getParameter("throw"))) {
throw new ServletException("Test Exception");
}

response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);

Expand Down
2 changes: 0 additions & 2 deletions managed_vms/async-rest/src/main/webapp/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions managed_vms/async-rest/src/main/webapp/WEB-INF/appengine-web.xml

This file was deleted.