From 3232a1557aabd1ef3a59cbea38c883d4abb7ff32 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Tue, 28 Mar 2017 00:35:02 -0400 Subject: add support for forking the jvm process when invoking a main class and add example of using akka-http that doesn’t work without this. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add functionality to emulate inheritIO when running via nailgun process. Only caveat right now: user has to press ENTER to terminate the input strea. --- examples/fork-example/Main.scala | 29 +++++++++++++++++++++++++++++ examples/fork-example/build/build.scala | 17 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/fork-example/Main.scala create mode 100644 examples/fork-example/build/build.scala (limited to 'examples') diff --git a/examples/fork-example/Main.scala b/examples/fork-example/Main.scala new file mode 100644 index 0000000..2ce5af8 --- /dev/null +++ b/examples/fork-example/Main.scala @@ -0,0 +1,29 @@ +package cbt_examples.fork_example + +import akka.http.scaladsl.server._ +import akka.http.scaladsl.model._ +import akka.http.scaladsl.server.Directives._ +import akka.http.scaladsl.settings._ + +object Service extends HttpApp with App { + // should all appear in separate lines + System.out.println("HelloHello") + System.err.println("HelloHello") + System.out.println("HelloHello") + System.err.println("HelloHello") + System.out.println("HelloHello") + System.err.println("HelloHello") + System.out.println("HelloHello") + System.err.println("HelloHello") + System.out.println("HelloHello") + System.err.println("HelloHello") + + override protected def route = + path("test") { + get { + complete(HttpResponse()) + } + } + + startServer("localhost", 8080) +} diff --git a/examples/fork-example/build/build.scala b/examples/fork-example/build/build.scala new file mode 100644 index 0000000..0f033ee --- /dev/null +++ b/examples/fork-example/build/build.scala @@ -0,0 +1,17 @@ +package cbt_examples_build.akka_example + +import cbt._ +import java.net.URL + +class Build(val context: Context) extends BaseBuild { + override def defaultScalaVersion = "2.12.1" + + override def fork = true + + override def dependencies = + super.dependencies ++ + Resolver(mavenCentral).bind( + ScalaDependency("com.typesafe.akka", "akka-http", "10.0.5") + ) + +} -- cgit v1.2.3