Skip to content

Instantly share code, notes, and snippets.

@tomasherman
Last active December 14, 2015 20:09
Show Gist options
  • Save tomasherman/5142050 to your computer and use it in GitHub Desktop.
Save tomasherman/5142050 to your computer and use it in GitHub Desktop.
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import org.eclipse.jetty.server.nio._
object RunWebApp extends App {
val server = new Server
val scc = new SelectChannelConnector
scc.setPort(8080)
server.setConnectors(Array(scc))
val context = new WebAppContext()
context.setServer(server)
context.setContextPath("/")
context.setWar("src/main/webapp")
server.setHandler(context)
try {
println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP")
server.start()
while (System.in.available() == 0) {
Thread.sleep(5000)
}
server.stop()
server.join()
} catch {
case exc : Exception => {
exc.printStackTrace()
System.exit(100)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment