docker akka y scala, inicio y fin de la aplicación justo después sin razón

Creé una aplicación Scala utilizando Akka.

Cuando lo ejecuto con: scala /Statistics.jar ./server.conf funciona perfectamente. pero si lo pongo en un server o si lo pongo en una image de acoplador, cuando lo ejecuto, la aplicación se inicia y luego se detiene inmediatamente después.

Aquí están mis loggings:

  ... [DEBUG] [02/01/2017 10:26:13.198] [webserver-akka.actor.default-dispatcher-11] [EventStream(akka://version)] logger log1-Slf4jLogger started [DEBUG] [02/01/2017 10:26:13.185] [subscription-akka.actor.default-dispatcher-4] [akka://subscription/system] now supervising Actor[akka://subscription/system/log1-Slf4jLogger#731298157] [DEBUG] [02/01/2017 10:26:13.201] [subscription-akka.actor.default-dispatcher-4] [akka://subscription/system] now watched by Actor[akka://subscription/] [DEBUG] [02/01/2017 10:26:13.202] [webserver-akka.actor.default-dispatcher-11] [EventStream(akka://version)] Default Loggers started [DEBUG] [02/01/2017 10:26:13.193] [version-akka.actor.default-dispatcher-2] [akka://version/system] now supervising Actor[akka://version/system/log1-Slf4jLogger#1075717908] [DEBUG] [02/01/2017 10:26:13.206] [session-akka.actor.default-dispatcher-3] [akka://session/system/UnhandledMessageForwarder] started (akka.event.LoggingBus$$anonfun$startDefaultLoggers$2$$anon$3@1b5d5357) [DEBUG] [02/01/2017 10:26:13.205] [webserver-akka.actor.default-dispatcher-13] [EventStream(akka://session)] Default Loggers started [DEBUG] [02/01/2017 10:26:13.205] [webserver-akka.actor.default-dispatcher-8] [EventStream(akka://subscription)] Default Loggers started [DEBUG] [02/01/2017 10:26:13.206] [subscription-akka.actor.default-dispatcher-4] [akka://subscription/system/UnhandledMessageForwarder] started (akka.event.LoggingBus$$anonfun$startDefaultLoggers$2$$anon$3@51839748) [DEBUG] [02/01/2017 10:26:13.211] [subscription-akka.actor.default-dispatcher-2] [akka://subscription/system] now supervising Actor[akka://subscription/system/UnhandledMessageForwarder#2056207919] serv http launch [DEBUG] [02/01/2017 10:26:15.906] [webserver-akka.actor.default-dispatcher-8] [EventStream] shutting down: StandardOutLogger started [DEBUG] [02/01/2017 10:26:15.909] [webserver-akka.actor.default-dispatcher-8] [EventStream] all default loggers stopped [DEBUG] [02/01/2017 10:26:15.909] [webserver-akka.actor.default-dispatcher-3] [akka://webserver/system/log1-Slf4jLogger] stopped [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-7] [akka://webserver/system/IO-TCP] stopping [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-12] [akka://webserver/system/UnhandledMessageForwarder] stopped [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-16] [akka://webserver/system/IO-TCP/selectors] stopping [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-8] [akka://webserver/system] stopping [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-3] [akka://webserver/system/deadLetterListener] stopped [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/system/IO-TCP/selectors/$a] no longer watched by Actor[akka://webserver/system/IO-TCP/selectors#1324110335] [DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-13] [akka://webserver/system/eventStreamUnsubscriber-1] stopped [DEBUG] [02/01/2017 10:26:15.911] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/system/IO-TCP/selectors/$a] stopped [DEBUG] [02/01/2017 10:26:15.911] [webserver-akka.actor.default-dispatcher-13] [akka://webserver/system/IO-TCP/selectors] stopped [DEBUG] [02/01/2017 10:26:15.912] [webserver-akka.actor.default-dispatcher-8] [akka://webserver/system/IO-TCP] stopped [DEBUG] [02/01/2017 10:26:15.912] [webserver-akka.actor.default-dispatcher-13] [akka://webserver/system] stopped [DEBUG] [02/01/2017 10:26:15.912] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/] received AutoReceiveMessage Envelope(Terminated(Actor[akka://webserver/system]),Actor[akka://webserver/system]) [DEBUG] [02/01/2017 10:26:15.913] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/] stopped 

Parece que no puedo iniciar mi aplicación en segundo plano. ¿Cómo puedo hacer para lanzarlo en segundo plano?

aquí está mi Main.scala:

 object WebServer extends App { implicit val system = ActorSystem("webserver") implicit val materializer = ActorMaterializer() // needed for the future flatMap/onComplete in the end implicit val executionContext = system.dispatcher val ipServer = InetAddress.getLocalHost().getHostAddress() val configApplication = ConfigFactory.load("application") val serverFile = new File(args(0)) val configServer = ConfigFactory.parseFile(serverFile) val routes = new AppActiveRoute(system.actorOf(AppActiveHandler.props(), "AppActiveHandler")).route val bindingFuture = Http().bindAndHandle( routes, ipServer, configApplication.getInt("http.port") ) println("serv http launch") StdIn.readLine() bindingFuture .flatMap(_.unbind()) // trigger unbinding from the port .onComplete(_ => { cluster.close() system.terminate() }) bindingFuture.onFailure { case ex: Exception => println(ex, "Failed to bind to {}:{}!", ipServer, configApplication.getInt("http.port")) } 

Si se supone que su aplicación debe ser dockerized y ejecutarse en un contenedor, es probable que no necesite esta parte

  StdIn.readLine() bindingFuture .flatMap(_.unbind()) // trigger unbinding from the port .onComplete(_ => { cluster.close() system.terminate() }) 

Intenta borrarlo

Si desea cerrar con gracia su sistema actor cuando la máquina virtual sale, puede usar un gancho de apagado, como se especifica en esta respuesta .