Skip to content

Commit

Permalink
akka-management の conf を切り出して、akka-management を使用する場合のみ明示的に akka-mana…
Browse files Browse the repository at this point in the history
…gement の設定を適応できるように修正
  • Loading branch information
kuramapommel committed Dec 11, 2024
1 parent 0768b55 commit ebdd13d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
### minikube を使用

1. `sbt assembly` コマンドで FAT jar ファイルを作成
2. `docker build --platform linux/arm64 -t til-akka-typed .` コマンドで docker image を作成
2. `docker build --platform linux/arm64 -t til-akka-typed --build-arg CONF=akka-management.conf .` コマンドで docker image を作成
- Apple Silicon の場合 `--platform linux/arm64` を指定
3. `docker tag til-akka-typed:latest kuramapommel/til-akka-typed:latest` コマンドで docekr image にタグ付け
4. `docker push kuramapommel/til-akka-typed:latest` コマンドで Docker Hub に docker image を送信
Expand Down
24 changes: 24 additions & 0 deletions sample/src/main/resources/akka-management.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include "persistence_docker-compose.conf"

til-akka-typed.use-akka-management = true

akka {
cluster.shutdown-after-unsuccessful-join-seed-nodes = 60s

management {
cluster.bootstrap {
contact-point-discovery {
discovery-method = kubernetes-api
required-contact-point-nr = 0
required-contact-point-nr = ${?REQUIRED_CONTACT_POINT_NR}
}
}
health-checks {
readiness-checks {
example-ready = "com.kuramapommel.til_akka_typed.HealthChecker"
}
}
}

coordinated-shutdown.exit-jvm = on
}
19 changes: 0 additions & 19 deletions sample/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,7 @@ akka {

cluster {
seed-nodes = ${?SEED_NODES}

shutdown-after-unsuccessful-join-seed-nodes = 60s

downing-provider-class = "akka.cluster.sbr.SplitBrainResolverProvider"
}

management {
cluster.bootstrap {
contact-point-discovery {
discovery-method = kubernetes-api
required-contact-point-nr = 0
required-contact-point-nr = ${?REQUIRED_CONTACT_POINT_NR}
}
}
health-checks {
readiness-checks {
example-ready = "com.kuramapommel.til_akka_typed.HealthChecker"
}
}
}

coordinated-shutdown.exit-jvm = on
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ def startHttpServer(routes: Route)(using system: ActorSystem[?]): Unit =
val routes = new ProductRoutes(productActor)
startHttpServer(routes.routes)

// akka.cluster.seed-nodes にノード情報が設定されているときは akka management を使わない
if context.system.settings.config.getStringList("akka.cluster.seed-nodes").isEmpty() then
// akka.management が設定されているときのみ akka management を使用する
if context.system.settings.config
.hasPath("til-akka-typed.use-akka-management")
then
AkkaManagement.get(classicSystem).start()
ClusterBootstrap.get(classicSystem).start()

Expand Down

0 comments on commit ebdd13d

Please sign in to comment.