mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:06:50 +00:00
feature/Add property database_query_timeout_in_seconds
This commit is contained in:
parent
3494ca5d2f
commit
07350c8fbd
@ -100,6 +100,9 @@ read_authentication_type_validation_requires_role=false
|
||||
## enable logging all the database queries in log file
|
||||
#logging.database.queries.enable=true
|
||||
|
||||
## enable logging all the database queries in log file
|
||||
#database_query_timeout_in_seconds=
|
||||
|
||||
##Added Props property_name_prefix, default is OBP_. This adds the prefix only for the system environment property name, eg: db.driver --> OBP_db.driver
|
||||
#system_environment_property_name_prefix=OBP_
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ import net.liftweb.util.Helpers._
|
||||
import net.liftweb.util.{DefaultConnectionIdentifier, Helpers, Props, Schedule, _}
|
||||
import org.apache.commons.io.FileUtils
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
||||
/**
|
||||
* A class that's instantiated early and run. It allows the application
|
||||
@ -279,6 +279,25 @@ class Boot extends MdcLoggable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Database query timeout
|
||||
APIUtil.getPropsValue("database_query_timeout_in_seconds").map { timeoutInSeconds =>
|
||||
tryo(timeoutInSeconds.toInt).isDefined match {
|
||||
case true =>
|
||||
DB.queryTimeout = Full(timeoutInSeconds.toInt)
|
||||
logger.info(s"Query timeout database_query_timeout_in_seconds is set to ${timeoutInSeconds} seconds")
|
||||
case false =>
|
||||
logger.error(
|
||||
s"""
|
||||
|------------------------------------------------------------------------------------
|
||||
|Query timeout database_query_timeout_in_seconds [${timeoutInSeconds}] is not an integer value.
|
||||
|Actual DB.queryTimeout value: ${DB.queryTimeout}
|
||||
|------------------------------------------------------------------------------------""".stripMargin)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
implicit val formats = CustomJsonFormats.formats
|
||||
LiftRules.statelessDispatch.prepend {
|
||||
case _ if tryo(DB.use(DefaultConnectionIdentifier){ conn => conn}.isClosed).isEmpty =>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user