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 1/5] =?UTF-8?q?watchdog-fe:=20grpc=E3=81=AE=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=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 -- 2.43.0 From 02a6428b8638844720fc8bc1f19e44c838615ec8 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:10:52 +0900 Subject: [PATCH 2/5] =?UTF-8?q?watchdog-fe:=20ci=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/watchdog-be-build.yaml | 29 +++++++++++++++++++++++++ watch-dog-be/build.gradle.kts | 2 +- watch-dog-be/gradlew | 0 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/watchdog-be-build.yaml mode change 100644 => 100755 watch-dog-be/gradlew diff --git a/.gitea/workflows/watchdog-be-build.yaml b/.gitea/workflows/watchdog-be-build.yaml new file mode 100644 index 0000000..ef1a9df --- /dev/null +++ b/.gitea/workflows/watchdog-be-build.yaml @@ -0,0 +1,29 @@ +on: + pull_request: + types: + - labeled + - opened + - synchronize + - closed + workflow_dispatch: +permissions: + pull-requests: read + +jobs: + build-watchdog-be: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + defaults: + run: + working-directory: ./watch-dog-be + if: contains(github.event.pull_request.labels.*.name,'watchdog-be') + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '21' + - uses: gradle/actions/setup-gradle@v3 + - run: ./gradlew jib -Djib.to.image=git.usbharu.dev/usbharu/watchdog-be -Djib.to.auth.username=usbharu -Djib.to.auth.password=${{ secrets.DEPLOY_TOKEN }} \ No newline at end of file diff --git a/watch-dog-be/build.gradle.kts b/watch-dog-be/build.gradle.kts index bc80f8a..45f4c60 100644 --- a/watch-dog-be/build.gradle.kts +++ b/watch-dog-be/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "dev.usbharu" -version = "1.0-SNAPSHOT" +version = "1.0.0" application { mainClass.set("io.ktor.server.netty.EngineMain") diff --git a/watch-dog-be/gradlew b/watch-dog-be/gradlew old mode 100644 new mode 100755 -- 2.43.0 From 16f9e9a48c85e8d0e84b4b3c2e3b9556f34dd30a Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:19:34 +0900 Subject: [PATCH 3/5] =?UTF-8?q?watchdog-fe:=20ci=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/watchdog-be-build.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/watchdog-be-build.yaml b/.gitea/workflows/watchdog-be-build.yaml index ef1a9df..53b3893 100644 --- a/.gitea/workflows/watchdog-be-build.yaml +++ b/.gitea/workflows/watchdog-be-build.yaml @@ -26,4 +26,7 @@ jobs: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '21' - uses: gradle/actions/setup-gradle@v3 - - run: ./gradlew jib -Djib.to.image=git.usbharu.dev/usbharu/watchdog-be -Djib.to.auth.username=usbharu -Djib.to.auth.password=${{ secrets.DEPLOY_TOKEN }} \ No newline at end of file + - uses: ./gradlew jibBuildTar + if: github.event.pull_request.merged == false + - run: ./gradlew jib -Djib.to.image=git.usbharu.dev/usbharu/watchdog-be -Djib.to.auth.username=usbharu -Djib.to.auth.password=${{ secrets.DEPLOY_TOKEN }} + if: github.event.pull_request.merged == true \ No newline at end of file -- 2.43.0 From 1aecadb3f508afc3ea95c451de4b77c6b213ff7e Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:22:56 +0900 Subject: [PATCH 4/5] =?UTF-8?q?watchdog-fe:=20ci=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- watch-dog-be/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/watch-dog-be/build.gradle.kts b/watch-dog-be/build.gradle.kts index 45f4c60..167907a 100644 --- a/watch-dog-be/build.gradle.kts +++ b/watch-dog-be/build.gradle.kts @@ -82,5 +82,6 @@ jib { ktor { docker { localImageName.set("watchdog-be") + this.imageTag = version.toString() } } \ No newline at end of file -- 2.43.0 From cfcb86e20dac0d46468fd3af12607e01b2f0c04a Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:26:15 +0900 Subject: [PATCH 5/5] =?UTF-8?q?watchdog-fe:=20ci=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/watchdog-be-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/watchdog-be-build.yaml b/.gitea/workflows/watchdog-be-build.yaml index 53b3893..a41582c 100644 --- a/.gitea/workflows/watchdog-be-build.yaml +++ b/.gitea/workflows/watchdog-be-build.yaml @@ -26,7 +26,7 @@ jobs: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '21' - uses: gradle/actions/setup-gradle@v3 - - uses: ./gradlew jibBuildTar + - run: ./gradlew jibBuildTar if: github.event.pull_request.merged == false - run: ./gradlew jib -Djib.to.image=git.usbharu.dev/usbharu/watchdog-be -Djib.to.auth.username=usbharu -Djib.to.auth.password=${{ secrets.DEPLOY_TOKEN }} if: github.event.pull_request.merged == true \ No newline at end of file -- 2.43.0