mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Shut down the Spark server more gracefully.
This commit is contained in:
parent
d084718fd6
commit
2367d7aab6
1 changed files with 10 additions and 3 deletions
|
@ -7,6 +7,7 @@ import com.google.gson.Gson
|
|||
import spark.ResponseTransformer
|
||||
import spark.Route
|
||||
import spark.Spark
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class SparkServer(val initCallback: (String) -> List<Project>, val cleanUpCallback: () -> Unit)
|
||||
: KobaltServer .IServer {
|
||||
|
@ -29,9 +30,15 @@ class SparkServer(val initCallback: (String) -> List<Project>, val cleanUpCallba
|
|||
override fun run(port: Int) {
|
||||
Spark.port(port)
|
||||
Spark.get("/ping", { req, res -> "The Kobalt server is up and running" })
|
||||
Spark.get("/quit", {
|
||||
req, res -> println("Kobalt server quitting...")
|
||||
Spark.get("/quit", { req, res ->
|
||||
Executors.newFixedThreadPool(1).let { executor ->
|
||||
executor.submit {
|
||||
Thread.sleep(1000)
|
||||
Spark.stop()
|
||||
executor.shutdown()
|
||||
}
|
||||
"ok"
|
||||
}
|
||||
})
|
||||
Spark.get("/v0/getDependencies", "application/json", Route { request, response ->
|
||||
val buildFile = request.queryParams("buildFile")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue