Skip to content

Commit

Permalink
Log current version and git commit hash at start
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Feb 15, 2025
1 parent c2ce0f6 commit 6884b21
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
15 changes: 12 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ val commonSettings = Seq(
)
)

val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](
version,
BuildInfoKey.map(git.gitHeadCommit) { case (k, v) => k -> v.getOrElse("unknown").take(7) }
),
buildInfoPackage := "lila.search"
)

lazy val core = project
.in(file("modules/core"))
.enablePlugins(Smithy4sCodegenPlugin)
Expand Down Expand Up @@ -72,10 +80,11 @@ lazy val api = project

lazy val ingestor = project
.in(file("modules/ingestor"))
.enablePlugins(Smithy4sCodegenPlugin)
.enablePlugins(JavaAppPackaging, Smithy4sCodegenPlugin, BuildInfoPlugin)
.settings(
name := "ingestor",
commonSettings,
buildInfoSettings,
publish := {},
publish / skip := true,
libraryDependencies ++= Seq(
Expand Down Expand Up @@ -109,7 +118,6 @@ lazy val ingestor = project
),
Compile / run / fork := true
)
.enablePlugins(JavaAppPackaging)
.dependsOn(elastic, core)

lazy val client = project
Expand All @@ -127,10 +135,12 @@ lazy val client = project
.dependsOn(api, core)

lazy val app = project
.enablePlugins(JavaAppPackaging, BuildInfoPlugin)
.in(file("modules/app"))
.settings(
name := "lila-search",
commonSettings,
buildInfoSettings,
publish := {},
publish / skip := true,
libraryDependencies ++= Seq(
Expand All @@ -153,7 +163,6 @@ lazy val app = project
),
Compile / run / fork := true
)
.enablePlugins(JavaAppPackaging)
.dependsOn(api, elastic)

val e2e = project
Expand Down
2 changes: 1 addition & 1 deletion modules/app/src/main/scala/app.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ object App extends IOApp.Simple:
apiRoutes <- Routes(res, config.server)
httpRoutes = apiRoutes <+> mkPrometheusRoutes
server <- MkHttpServer().newEmber(config.server, httpRoutes.orNotFound)
_ <- Logger[IO].info(s"Starting server on ${config.server.host}:${config.server.port}").toResource
_ <- Logger[IO].info(s"BuildInfo: ${BuildInfo}").toResource
yield ()
9 changes: 6 additions & 3 deletions modules/ingestor/src/main/scala/app.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ object App extends IOApp.Simple:
_ <- RuntimeMetrics.register[IO]
_ <- IOMetrics.register[IO]()
config <- AppConfig.load.toResource
_ <- Logger[IO].info(s"Starting lila-search ingestor with config: $config").toResource
res <- AppResources.instance(config)
_ <- IngestorApp(res, config).run()
gitCommit = BuildInfo.gitHeadCommit.take(7)
version = BuildInfo.version
_ <- Logger[IO].info(s"Starting lila-search ingestor with config: $config").toResource
_ <- Logger[IO].info(s"BuildInfo: ${BuildInfo}").toResource
res <- AppResources.instance(config)
_ <- IngestorApp(res, config).run()
yield ()

def mkMeter = SdkMetrics
Expand Down
4 changes: 4 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.0")

addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % "0.18.29")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")

addSbtPlugin("com.github.sbt" % "sbt-git" % "2.1.0")

addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.11.0")

addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
Expand Down

0 comments on commit 6884b21

Please sign in to comment.