Skip to content

Commit

Permalink
Merge pull request #73 from open-horizon/max-threads-warning
Browse files Browse the repository at this point in the history
Configure AsyncExecutor to prevent warning
  • Loading branch information
bmpotter authored May 2, 2018
2 parents fb4a1d6 + 27a90f1 commit 4899dd7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/scala/ScalatraBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ class ScalatraBootstrap extends LifeCycle {
*/
override def init(context: ServletContext) {
// val db = if (cpds != null) Database.forDataSource(cpds) else null
val db = if (cpds != null) Database.forDataSource(cpds, Option(50)) else null
val maxConns = ExchConfig.getInt("api.db.maxPoolSize")
val db =
if (cpds != null) {
Database.forDataSource(
cpds,
Some(maxConns),
AsyncExecutor("ExchangeExecutor", maxConns, maxConns, 1000, maxConns)
)
} else null

// Disable scalatra's builtin CorsSupport because for some inexplicable reason it doesn't set Access-Control-Allow-Origin which is critical
context.setInitParameter("org.scalatra.cors.enable", "false")
Expand Down Expand Up @@ -72,4 +80,4 @@ class ScalatraBootstrap extends LifeCycle {
cpds.setAcquireIncrement(ExchConfig.getInt("api.db.acquireIncrement"))
cpds.setMaxPoolSize(ExchConfig.getInt("api.db.maxPoolSize"))
}
}
}

0 comments on commit 4899dd7

Please sign in to comment.