From aeeced4f710e58628ba80851d1d792f51e877d9e Mon Sep 17 00:00:00 2001 From: Jorge Vicente Cantero Date: Tue, 15 Jan 2019 20:09:41 +0100 Subject: [PATCH] Signal shutdown via nailgun common pool in `exit` --- frontend/src/main/scala/bloop/Server.scala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/src/main/scala/bloop/Server.scala b/frontend/src/main/scala/bloop/Server.scala index e5d3093c13..54d63e1deb 100644 --- a/frontend/src/main/scala/bloop/Server.scala +++ b/frontend/src/main/scala/bloop/Server.scala @@ -25,7 +25,17 @@ object Server { def nailMain(ngContext: NGContext): Unit = { val server = ngContext.getNGServer - shutDown(server) + import java.util.concurrent.ForkJoinPool + + ForkJoinPool + .commonPool() + .submit(new Runnable { + override def run(): Unit = { + server.shutdown(false) + } + }) + + () } private def run(server: NGServer): Unit = { @@ -52,7 +62,7 @@ object Server { new Alias( "exit", "Kill the bloop server.", - classOf[com.martiansoftware.nailgun.builtins.NGStop] + classOf[Server] ) ) @@ -61,8 +71,4 @@ object Server { // Disable nails by class name so that we prevent classloading incorrect aliases server.setAllowNailsByClassName(false) } - - private def shutDown(server: NGServer): Unit = { - server.shutdown( /* exitVM = */ false) - } }