Commits

Anonymous committed e41dd71

modify port setting

Comments (0)

Files changed (1)

src/main/java/examples/HelloWorld.java

 	}
 
 	public static void main(String[] args) throws Exception {
-		
+
+		int port = 8080;
+		String p = System.getenv("PORT");
+		if (p != null && 0 < p.length()) {
+			port = Integer.valueOf(p);
+		}
 		PackagesResourceConfig config = new PackagesResourceConfig("examples");
 		ServletContainer container = new ServletContainer(config);
-		
-		ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
+
+		ServletContextHandler context = new ServletContextHandler(
+				ServletContextHandler.NO_SESSIONS);
 		context.setContextPath("/");
 		context.addServlet(new ServletHolder(container), "/*");
-		
-		Server server = new Server(8080);
+
+		Server server = new Server(port);
 		server.setHandler(context);
 
 		server.start();