diff options
-rw-r--r-- | Plugin.scala | 24 | ||||
-rw-r--r-- | Server.scala | 3 |
2 files changed, 7 insertions, 20 deletions
diff --git a/Plugin.scala b/Plugin.scala index 512e195..81359a5 100644 --- a/Plugin.scala +++ b/Plugin.scala @@ -1,22 +1,10 @@ package com.lihaoyi.workbench -import akka.actor.{ActorRef, Actor, ActorSystem} -import scala.concurrent.duration._ - - import sbt._ import Keys._ -import akka.actor.ActorDSL._ -import com.typesafe.config.ConfigFactory import upickle._ -import spray.http.{AllOrigins, HttpResponse} -import spray.routing.SimpleRoutingApp -import spray.http.HttpHeaders.`Access-Control-Allow-Origin` - object Plugin extends sbt.Plugin { - - val refreshBrowsers = taskKey[Unit]("Sends a message to all connected web pages asking them to refresh the page") val updateBrowsers = taskKey[Unit]("partially resets some of the stuff in the browser") val localUrl = settingKey[(String, Int)]("localUrl") @@ -83,14 +71,10 @@ object Plugin extends sbt.Plugin { } } }, - server := { - new Server(localUrl.value._1, localUrl.value._2, bootSnippet.value) - }, - onLoad := { state => - state - }, - onUnload := { state => + server := new Server(localUrl.value._1, localUrl.value._2, bootSnippet.value), + (onUnload in Global) := { (onUnload in Global).value.compose{ state => + server.value.kill() state - } + }} ) } diff --git a/Server.scala b/Server.scala index af4b6b6..b9773a7 100644 --- a/Server.scala +++ b/Server.scala @@ -74,4 +74,7 @@ class Server(url: String, port: Int, bootSnippet: String) extends SimpleRoutingA def msg[T: Writer](t: T) = { pubSub ! upickle.writeJs(t) } + def kill() = { + system.shutdown() + } }
\ No newline at end of file |