GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make sure samples listen to PORT env var (#1598) · dmichel1/java-docs-samples@501af84

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • appengine-java11
    • appengine-simple-jetty-main/src/main/java/com/example/appengine/demo/jettymain
      • Main.java
    • quarkus-helloworld
      • pom.xml
      • src/main/resources
        • application.properties
    • springboot-helloworld/src/main/resources
      • application.properties
    • vertx-helloworld/src/main/java/com/example/appengine/vertxhello
      • Application.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎appengine-java11/appengine-simple-jetty-main/src/main/java/com/example/appengine/demo/jettymain/Main.java‎

Copy file name to clipboardExpand all lines: appengine-java11/appengine-simple-jetty-main/src/main/java/com/example/appengine/demo/jettymain/Main.java
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ public static void main(String[] args) throws Exception {
3434

3535
// Create a basic Jetty server object that will listen on port defined by
3636
// the PORT environment variable when present, otherwise on 8080.
37-
// Note: If you set this to port 0, a randomly available port will be
38-
// assigned. You can find the assigned port in the logs or programmatically
39-
// obtain it.
4037
int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "8080"));
4138
Server server = new Server(port);
4239

Collapse file

‎appengine-java11/quarkus-helloworld/pom.xml‎

Copy file name to clipboardExpand all lines: appengine-java11/quarkus-helloworld/pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<!-- Copy dependencies of exploded fatjar to appengine-staging directory -->
8383
<configuration>
8484
<libDir>${project.build.directory}/appengine-staging/lib</libDir>
85-
<finalName>${project.build.directory}/appengine-staging/${build.finalName}</finalName>
85+
<finalName>${project.build.directory}/appengine-staging/${project.build.finalName}</finalName>
8686
</configuration>
8787
</plugin>
8888
<!-- Set Surefire version to work with Junit5 -->
Collapse file

‎appengine-java11/quarkus-helloworld/src/main/resources/application.properties‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019 Google LLC
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+
15+
# Set the port to the PORT environment variable
16+
quarkus.http.port=${PORT:8080}
Collapse file

‎appengine-java11/springboot-helloworld/src/main/resources/application.properties‎

Copy file name to clipboardExpand all lines: appengine-java11/springboot-helloworld/src/main/resources/application.properties
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# Set the port to the PORT environment variable
16+
server.port=${PORT:8080}
Collapse file

‎appengine-java11/vertx-helloworld/src/main/java/com/example/appengine/vertxhello/Application.java‎

Copy file name to clipboardExpand all lines: appengine-java11/vertx-helloworld/src/main/java/com/example/appengine/vertxhello/Application.java
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ public void start(Future<Void> startFuture) {
3737
Router router = Router.router(vertx);
3838
router.route().handler(this::handleDefault);
3939

40+
// Get the PORT environment variable for the server object to listen on
41+
int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "8080"));
42+
4043
vertx
4144
.createHttpServer()
4245
.requestHandler(router)
43-
.listen(8080, ar -> startFuture.handle(ar.mapEmpty()));
46+
.listen(port, ar -> startFuture.handle(ar.mapEmpty()));
4447
}
4548

4649
private void handleDefault(RoutingContext routingContext) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.