Skip to content

Commit

Permalink
Allow Kamon config to read from env variables
Browse files Browse the repository at this point in the history
Because of `run/fork:=true`, We can set system properties when
execute `sbt app/run`. So, we need a way to Kamon's config to read
from environment variables. Which is enabled by setting
`-Dconfig.override_with_env_vars=true` in `run` option.

More info here:
https://github.com/lightbend/config#optional-system-or-env-variable-overrides
  • Loading branch information
lenguyenthanh committed Dec 3, 2023
1 parent dadb9b0 commit 2c9150f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Start with default config:
sbt app/run
```

Use environment variables to start with custom config (`redis.host` for example):
Use environment variables to start with custom config (`redis.host` and `kamon` for example):
```sh
REDIS_HOST=redis sbt app/run
REDIS_HOST=redis KAMON_ENABLED=true CONFIG_FORCE_kamon_influxdb_port=8888 sbt app/run
```

For other `config` check [AppConfig.scala](https://github.com/lichess-org/lila-fishnet/blob/master/app/src/main/scala/AppConfig.scala)
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ inThisBuild(
scalaVersion := "3.3.1",
versionScheme := Some("early-semver"),
version := "3.0",
run / fork := true
run / fork := true,
run / javaOptions += "-Dconfig.override_with_env_vars=true"
)
)

Expand Down Expand Up @@ -41,13 +42,12 @@ lazy val app = project
testContainers,
log4CatsNoop,
http4sClient,
catsEffectTestKit,
catsEffectTestKit
),
javaAgents += kamonAgent,
javaAgents += kamonAgent
)
.enablePlugins(JavaAppPackaging, JavaAgent)


lazy val root = project
.in(file("."))
.aggregate(app)

0 comments on commit 2c9150f

Please sign in to comment.