This is an automated email from the ASF dual-hosted git repository.

zhaoqingran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 778666c50 [Improve] run hertzbeat in docker compose support dependen 
service condition (#1748)
778666c50 is described below

commit 778666c504c3f4ba67c38f75afd1cd8e3c16a29b
Author: Gao Jian <[email protected]>
AuthorDate: Mon Apr 15 17:52:44 2024 +0800

    [Improve] run hertzbeat in docker compose support dependen service 
condition (#1748)
---
 .../hertzbeat-mysql-iotdb/docker-compose.yaml      | 17 ++++++++++--
 .../hertzbeat-mysql-tdengine/docker-compose.yaml   | 17 ++++++++++--
 .../docker-compose.yaml                            | 17 ++++++++++--
 .../conf/application.yml                           | 32 +++++++++++-----------
 .../hertzbeat-postgresql-iotdb/docker-compose.yaml | 18 ++++++++++--
 5 files changed, 77 insertions(+), 24 deletions(-)

diff --git a/script/docker-compose/hertzbeat-mysql-iotdb/docker-compose.yaml 
b/script/docker-compose/hertzbeat-mysql-iotdb/docker-compose.yaml
index 2f0347c58..73229c308 100644
--- a/script/docker-compose/hertzbeat-mysql-iotdb/docker-compose.yaml
+++ b/script/docker-compose/hertzbeat-mysql-iotdb/docker-compose.yaml
@@ -25,6 +25,11 @@ services:
     container_name: compose-mysql
     hostname: mysql
     restart: always
+    healthcheck:
+      test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --silent']
+      interval: 3s
+      retries: 5
+      start_period: 3m
     ports:
       - "3306"
     environment:
@@ -41,6 +46,12 @@ services:
     container_name: compose-iotdb
     hostname: iotdb
     restart: always
+    healthcheck:
+      test: ["CMD", "ls", "/iotdb/data"]
+      interval: 10s
+      retries: 5
+      timeout: 5s
+      start_period: 30s
     environment:
       TZ: Asia/Shanghai
     ports:
@@ -60,8 +71,10 @@ services:
       TZ: Asia/Shanghai
       LANG: zh_CN.UTF-8
     depends_on:
-      - mysql
-      - iotdb
+      mysql:
+        condition: service_healthy
+      iotdb:
+        condition: service_healthy
     volumes:
       - ./conf/application.yml:/opt/hertzbeat/config/application.yml
       - ./conf/sureness.yml:/opt/hertzbeat/config/sureness.yml
diff --git a/script/docker-compose/hertzbeat-mysql-tdengine/docker-compose.yaml 
b/script/docker-compose/hertzbeat-mysql-tdengine/docker-compose.yaml
index 4ce4570f8..30cb3d0d0 100644
--- a/script/docker-compose/hertzbeat-mysql-tdengine/docker-compose.yaml
+++ b/script/docker-compose/hertzbeat-mysql-tdengine/docker-compose.yaml
@@ -25,6 +25,11 @@ services:
     container_name: compose-mysql
     hostname: mysql
     restart: always
+    healthcheck:
+      test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --silent']
+      interval: 3s
+      retries: 5
+      start_period: 3m
     ports:
       - "3306"
     environment:
@@ -41,6 +46,12 @@ services:
     container_name: compose-tdengine
     hostname: tdengine
     restart: always
+    healthcheck:
+      test: ['CMD-SHELL', 'curl -u root:taosdata -d "show databases" 
tdengine:6041/rest/sql']
+      interval: 10s
+      retries: 5
+      timeout: 5s
+      start_period: 1m
     environment:
       TZ: Asia/Shanghai
     ports:
@@ -59,8 +70,10 @@ services:
       TZ: Asia/Shanghai
       LANG: zh_CN.UTF-8
     depends_on:
-      - mysql
-      - tdengine
+      mysql:
+        condition: service_healthy
+      tdengine:
+        condition: service_healthy
     volumes:
       - ./conf/application.yml:/opt/hertzbeat/config/application.yml
       - ./conf/sureness.yml:/opt/hertzbeat/config/sureness.yml
diff --git 
a/script/docker-compose/hertzbeat-mysql-victoria-metrics/docker-compose.yaml 
b/script/docker-compose/hertzbeat-mysql-victoria-metrics/docker-compose.yaml
index 9aede0d75..ab003fed9 100644
--- a/script/docker-compose/hertzbeat-mysql-victoria-metrics/docker-compose.yaml
+++ b/script/docker-compose/hertzbeat-mysql-victoria-metrics/docker-compose.yaml
@@ -25,6 +25,11 @@ services:
     container_name: compose-mysql
     hostname: mysql
     restart: always
+    healthcheck:
+      test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --silent']
+      interval: 3s
+      retries: 5
+      start_period: 3m
     ports:
       - "3306"
     environment:
@@ -41,6 +46,12 @@ services:
     container_name: compose-victoria-metrics
     hostname: victoria-metrics
     restart: always
+    healthcheck:
+      test: ["CMD", "wget", "-q", "-O", "-", 
"http://victoria-metrics:8428/-/healthy";]
+      interval: 10s
+      retries: 5
+      timeout: 5s
+      start_period: 30s
     environment:
       TZ: Asia/Shanghai
     ports:
@@ -59,8 +70,10 @@ services:
       TZ: Asia/Shanghai
       LANG: zh_CN.UTF-8
     depends_on:
-      - mysql
-      - victoria-metrics
+      mysql:
+        condition: service_healthy
+      victoria-metrics:
+        condition: service_healthy
     volumes:
       - ./conf/application.yml:/opt/hertzbeat/config/application.yml
       - ./conf/sureness.yml:/opt/hertzbeat/config/sureness.yml
diff --git 
a/script/docker-compose/hertzbeat-postgresql-iotdb/conf/application.yml 
b/script/docker-compose/hertzbeat-postgresql-iotdb/conf/application.yml
index eb4889d90..34dccf353 100644
--- a/script/docker-compose/hertzbeat-postgresql-iotdb/conf/application.yml
+++ b/script/docker-compose/hertzbeat-postgresql-iotdb/conf/application.yml
@@ -81,22 +81,22 @@ spring:
 
   # Not Require, Please config if you need email notify
   # 非必填:不使用邮箱作为警告通知可以去掉spring.mail配置
-#  mail:
-#    # Attention: this is mail server address.
-#    # 请注意此为邮件服务器地址:qq邮箱为 smtp.qq.com qq企业邮箱为 smtp.exmail.qq.com
-#    host: smtp.qq.com
-#    username: [email protected]
-#    # Attention: this is not email account password, this requires an email 
authorization code
-#    # 请注意此非邮箱账户密码 此需填写邮箱授权码
-#    password: xxqzvuqbnqvbbdac
-#    port: 465
-#    default-encoding: UTF-8
-#    properties:
-#      mail:
-#        smtp:
-#          socketFactoryClass: javax.net.ssl.SSLSocketFactory
-#          ssl:
-#            enable: true
+  mail:
+    # Attention: this is mail server address.
+    # 请注意此为邮件服务器地址:qq邮箱为 smtp.qq.com qq企业邮箱为 smtp.exmail.qq.com
+    host: smtp.qq.com
+    username: [email protected]
+    # Attention: this is not email account password, this requires an email 
authorization code
+    # 请注意此非邮箱账户密码 此需填写邮箱授权码
+    password: xxqzvuqbnqvbbdac
+    port: 465
+    default-encoding: UTF-8
+    properties:
+      mail:
+        smtp:
+          socketFactoryClass: javax.net.ssl.SSLSocketFactory
+          ssl:
+            enable: true
 
 warehouse:
   store:
diff --git 
a/script/docker-compose/hertzbeat-postgresql-iotdb/docker-compose.yaml 
b/script/docker-compose/hertzbeat-postgresql-iotdb/docker-compose.yaml
index e75f88bdd..1ea72052e 100644
--- a/script/docker-compose/hertzbeat-postgresql-iotdb/docker-compose.yaml
+++ b/script/docker-compose/hertzbeat-postgresql-iotdb/docker-compose.yaml
@@ -25,6 +25,12 @@ services:
     container_name: compose-postgresql
     hostname: postgresql
     restart: always
+    healthcheck:
+      test: [ "CMD", "pg_isready" ]
+      interval: 10s
+      timeout: 5s
+      retries: 5
+      start_period: 30s
     ports:
       - '5432:5432'
     environment:
@@ -41,6 +47,12 @@ services:
     container_name: compose-iotdb
     hostname: iotdb
     restart: always
+    healthcheck:
+      test: ["CMD", "ls", "/iotdb/data"]
+      interval: 10s
+      timeout: 5s
+      retries: 5
+      start_period: 30s
     environment:
       TZ: Asia/Shanghai
     ports:
@@ -60,8 +72,10 @@ services:
       TZ: Asia/Shanghai
       LANG: zh_CN.UTF-8
     depends_on:
-      - postgres
-      - iotdb
+      postgres:
+        condition: service_healthy
+      iotdb:
+        condition: service_healthy
     volumes:
       - ./conf/application.yml:/opt/hertzbeat/config/application.yml
       - ./conf/sureness.yml:/opt/hertzbeat/config/sureness.yml


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to