diff --git a/.github/workflows/dependency-graph.yml b/.github/workflows/dependency-graph.yml index 8b68b37..05eb249 100644 --- a/.github/workflows/dependency-graph.yml +++ b/.github/workflows/dependency-graph.yml @@ -13,4 +13,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: scalacenter/sbt-dependency-submission@v2 \ No newline at end of file + - uses: scalacenter/sbt-dependency-submission@v3 \ No newline at end of file diff --git a/app/controllers/HealthController.scala b/app/controllers/HealthController.scala index f8e53d2..2e423d0 100644 --- a/app/controllers/HealthController.scala +++ b/app/controllers/HealthController.scala @@ -16,7 +16,7 @@ class HealthController @Inject()(reactiveMongoApi: ReactiveMongoApi, components: def livenessCheck: Action[AnyContent] = Action { Ok } - def readynessCheck: Action[AnyContent] = + def readinessCheck: Action[AnyContent] = Action.async { _ => reactiveMongoApi.database.flatMap(runPing).transform { case Success(true) => Success(Ok) diff --git a/app/filters/LoggingFilter.scala b/app/filters/LoggingFilter.scala new file mode 100644 index 0000000..875f0ea --- /dev/null +++ b/app/filters/LoggingFilter.scala @@ -0,0 +1,25 @@ +package filters + +import akka.stream.Materializer +import play.api.Logging +import play.api.mvc._ + +import javax.inject.Inject +import scala.concurrent.{ExecutionContext, Future} + +class LoggingFilter @Inject()(implicit override val mat: Materializer, ec: ExecutionContext) extends Filter with Logging { + def apply(nextFilter: RequestHeader => Future[Result])(requestHeader: RequestHeader): Future[Result] = { + val startTime = System.currentTimeMillis + + nextFilter(requestHeader).map { result => + val endTime = System.currentTimeMillis + val requestTime = endTime - startTime + + logger.info( + s"${requestHeader.method} ${requestHeader.uri} took ${requestTime}ms and returned ${result.header.status}" + ) + + result + } + } +} \ No newline at end of file diff --git a/build.sbt b/build.sbt index d823606..efe9df2 100644 --- a/build.sbt +++ b/build.sbt @@ -70,6 +70,8 @@ lazy val dockerSettings = Seq( dockerRepository := Some("docker.htrc.illinois.edu"), dockerUpdateLatest := true, Universal / javaOptions ++= Seq( + "-J-Xmx8G", + "-J-Xss1M", // don't write any pid files "-Dpidfile.path=/dev/null", // reference a logback config file that has no file appenders diff --git a/conf/application.conf b/conf/application.conf index 5720725..8f68c66 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -236,6 +236,7 @@ play.filters { enabled += play.filters.cors.CORSFilter enabled += play.filters.gzip.GzipFilter enabled += filters.InfoFilter + enabled += filters.LoggingFilter disabled += play.filters.hosts.AllowedHostsFilter disabled += play.filters.headers.SecurityHeadersFilter diff --git a/conf/logback-prod.xml b/conf/logback-prod.xml index b1097af..42192eb 100644 --- a/conf/logback-prod.xml +++ b/conf/logback-prod.xml @@ -25,7 +25,7 @@ - + diff --git a/conf/logback.xml b/conf/logback.xml index 7b0ae1d..e5b9c86 100644 --- a/conf/logback.xml +++ b/conf/logback.xml @@ -36,7 +36,7 @@ - + diff --git a/conf/routes b/conf/routes index ee3e89e..36cce23 100644 --- a/conf/routes +++ b/conf/routes @@ -11,7 +11,7 @@ GET /assets/*file controllers.Assets.versioned(path = "/public #GET /swagger.json controllers.Assets.at(path = "/public", file = "swagger.json") GET /health/liveness controllers.HealthController.livenessCheck -GET /health/readiness controllers.HealthController.readynessCheck +GET /health/readiness controllers.HealthController.readinessCheck GET /volumes/:cleanId controllers.EfController.getVolume(cleanId, pos: Boolean ?= true, fields: Option[String] ?= None) HEAD /volumes/:cleanId controllers.EfController.checkVolume(cleanId)