watchdog-fe: grpcのポートを指定できるように

This commit is contained in:
usbharu 2024-03-14 14:01:17 +09:00
parent 697b16be63
commit c2e0742c10
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
3 changed files with 7 additions and 4 deletions

View File

@ -3,8 +3,8 @@ package dev.usbharu.unos.watchdog.be
import io.grpc.ServerBuilder import io.grpc.ServerBuilder
import io.ktor.server.application.* import io.ktor.server.application.*
fun Application.grpc(pushMetricsService: PushMetricsService){ fun Application.grpc(port:Int,pushMetricsService: PushMetricsService){
val server = ServerBuilder.forPort(50051) val server = ServerBuilder.forPort(port)
.addService(pushMetricsService) .addService(pushMetricsService)
.build() .build()

View File

@ -22,6 +22,7 @@ fun Application.module() {
val url = environment.config.property("watchdog.db.url").getString() val url = environment.config.property("watchdog.db.url").getString()
val databaseName = environment.config.property("watchdog.db.database").getString() val databaseName = environment.config.property("watchdog.db.database").getString()
val grpcPort = environment.config.property("watchdog.grpc.port").getString().toInt()
val database = val database =
MongoClient MongoClient
.create( .create(
@ -33,7 +34,7 @@ fun Application.module() {
val mongoMetricsRepository = MongoMetricsRepository(database) val mongoMetricsRepository = MongoMetricsRepository(database)
grpc(PushMetricsService(mongoMetricsRepository)) grpc(grpcPort,PushMetricsService(mongoMetricsRepository))
routing { routing {
api(ApiController(mongoMetricsRepository)) api(ApiController(mongoMetricsRepository))
} }

View File

@ -13,6 +13,8 @@ watchdog {
url = "mongodb://localhost:27017" url = "mongodb://localhost:27017"
database = "watchdog" database = "watchdog"
} }
grpc {
port = 50051
}
} }