Skip to content

Commit

Permalink
Updated to heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Hohyon Ryu committed Feb 1, 2017
1 parent 53032ae commit ecbda97
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/main/java/org/openkoreantext/heroku/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.openkoreantext.heroku;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
* This class launches the web application in an embedded Jetty container. This is the entry point to your application. The Java
* command that is used for launching should fire this main method.
*/
public class Main {

public static void main(String[] args) throws Exception{
// The port that we should run on can be set into an environment variable
// Look for that variable and default to 8080 if it isn't there.
String webPort = System.getenv("PORT");
if (webPort == null || webPort.isEmpty()) {
webPort = "8080";
}

final Server server = new Server(Integer.valueOf(webPort));
final WebAppContext root = new WebAppContext();

root.setContextPath("/");
// Parent loader priority is a class loader setting that Jetty accepts.
// By default Jetty will behave like most web containers in that it will
// allow your application to replace non-server libraries that are part of the
// container. Setting parent loader priority to true changes this behavior.
// Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
root.setParentLoaderPriority(true);

final String webappDirLocation = "src/main/webapp/";
root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
root.setResourceBase(webappDirLocation);

server.setHandler(root);

server.start();
server.join();
}
}
19 changes: 19 additions & 0 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.openkoreantext</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
1 change: 1 addition & 0 deletions system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version=1.7

0 comments on commit ecbda97

Please sign in to comment.