Commit 6a1dbd4c authored by bow's avatar bow
Browse files

Exit immediately if bootstrap can not connect to database

parent 9163d026
......@@ -19,6 +19,7 @@ import com.typesafe.config.ConfigFactory
import javax.servlet.ServletContext
import org.scalatra.LifeCycle
import org.scalatra.swagger.ApiKey
import org.slf4j.LoggerFactory
import scala.util.Try
import nl.lumc.sasc.sentinel.{ HeaderApiKey, settings }, settings._
......@@ -35,6 +36,8 @@ class ScalatraBootstrap extends LifeCycle {
// TODO: how to add this in the object definitions itself?
swagger.addAuthorization(ApiKey(HeaderApiKey, "header"))
val logger = LoggerFactory.getLogger(getClass)
override def init(context: ServletContext) {
val conf = ConfigFactory.load()
......@@ -47,7 +50,13 @@ class ScalatraBootstrap extends LifeCycle {
implicit val runsProcessors = Set(makeDelayedProcessor[GentrapRunsProcessor])
// Check that we have a live connection to the DB
try {
} catch {
case e: Exception =>
logger.error("Could not connect to database. Exiting immediately.")
// TODO: separate production and development behavior more cleanly
try {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment