Skip to content

Commit

Permalink
Fix dbtool schema scheck stderr capturing (#6830)
Browse files Browse the repository at this point in the history
  • Loading branch information
fm3 authored Feb 7, 2023
1 parent 9de481c commit e2036fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Startup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ class Startup @Inject()(actorSystem: ActorSystem,

val errorMessageBuilder = mutable.ListBuffer[String]()
val capturingProcessLogger =
ProcessLogger((o: String) => errorMessageBuilder.append(o), (e: String) => logger.error(e))
ProcessLogger((o: String) => errorMessageBuilder.append(o), (e: String) => errorMessageBuilder.append(e))

val result = Process("./tools/postgres/dbtool.js check-db-schema", None, "POSTGRES_URL" -> postgresUrl) ! capturingProcessLogger
if (result == 0) {
logger.info("Database schema is up to date.")
} else {
val errorMessage = errorMessageBuilder.toList.mkString("\n")
logger.error(errorMessage)
logger.error("dbtool: " + errorMessage)
slackNotificationService.warn("SQL schema mismatch", errorMessage)
}
}

private def ensurePostgresDatabase(): Unit = {
logger.info(s"Ensuring Postgres database…")
val processLogger = ProcessLogger((o: String) => logger.info(o), (e: String) => logger.error(e))
val processLogger =
ProcessLogger((o: String) => logger.info(s"dbtool: $o"), (e: String) => logger.error(s"dbtool: $e"))

// this script is copied to the stage directory in AssetCompilation
val result = Process("./tools/postgres/dbtool.js ensure-db", None, "POSTGRES_URL" -> postgresUrl) ! processLogger
Expand Down

0 comments on commit e2036fd

Please sign in to comment.