From c2e0742c102833214c807c16efb0d5b004372895 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:01:17 +0900 Subject: [PATCH] =?UTF-8?q?watchdog-fe:=20grpc=E3=81=AE=E3=83=9D=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/dev/usbharu/unos/watchdog/be/GrpcServer.kt | 4 ++-- .../src/main/kotlin/dev/usbharu/unos/watchdog/be/Main.kt | 3 ++- watch-dog-be/src/main/resources/application.conf | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/GrpcServer.kt b/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/GrpcServer.kt index 60af29b..2e35293 100644 --- a/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/GrpcServer.kt +++ b/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/GrpcServer.kt @@ -3,8 +3,8 @@ package dev.usbharu.unos.watchdog.be import io.grpc.ServerBuilder import io.ktor.server.application.* -fun Application.grpc(pushMetricsService: PushMetricsService){ - val server = ServerBuilder.forPort(50051) +fun Application.grpc(port:Int,pushMetricsService: PushMetricsService){ + val server = ServerBuilder.forPort(port) .addService(pushMetricsService) .build() diff --git a/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/Main.kt b/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/Main.kt index d513809..5ffbf2c 100644 --- a/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/Main.kt +++ b/watch-dog-be/src/main/kotlin/dev/usbharu/unos/watchdog/be/Main.kt @@ -22,6 +22,7 @@ fun Application.module() { val url = environment.config.property("watchdog.db.url").getString() val databaseName = environment.config.property("watchdog.db.database").getString() + val grpcPort = environment.config.property("watchdog.grpc.port").getString().toInt() val database = MongoClient .create( @@ -33,7 +34,7 @@ fun Application.module() { val mongoMetricsRepository = MongoMetricsRepository(database) - grpc(PushMetricsService(mongoMetricsRepository)) + grpc(grpcPort,PushMetricsService(mongoMetricsRepository)) routing { api(ApiController(mongoMetricsRepository)) } diff --git a/watch-dog-be/src/main/resources/application.conf b/watch-dog-be/src/main/resources/application.conf index 3a2f778..ee08044 100644 --- a/watch-dog-be/src/main/resources/application.conf +++ b/watch-dog-be/src/main/resources/application.conf @@ -13,6 +13,8 @@ watchdog { url = "mongodb://localhost:27017" database = "watchdog" } - + grpc { + port = 50051 + } } \ No newline at end of file