Преглед изворни кода

Optimize healthchecks and make them consistent (#1330)

YAML anchors ftw
Mark Shust пре 1 месец
родитељ
комит
6563e6b506
1 измењених фајлова са 16 додато и 15 уклоњено
  1. 16 15
      compose/compose.healthcheck.yaml

+ 16 - 15
compose/compose.healthcheck.yaml

@@ -1,7 +1,17 @@
+x-healthcheck-defaults: &healthcheck-defaults
+  interval: 5s
+  timeout: 5s
+  retries: 3
+
+x-healthcheck-slow-start: &healthcheck-slow-start
+  <<: *healthcheck-defaults
+  start_period: 5s
+
 services:
   app:
     healthcheck:
       test: "curl --fail 127.0.0.1:8000"
+      <<: *healthcheck-defaults
     depends_on:
       phpfpm:
         condition: service_started
@@ -22,38 +32,29 @@ services:
   db:
     healthcheck:
       test: "mysqladmin ping -h localhost -u root -pmagento || mariadb-admin ping -h localhost -u root -pmagento"
-      interval: 5s
-      timeout: 5s
-      retries: 30
+      <<: *healthcheck-defaults
 
   redis:
     healthcheck:
       test: "redis-cli ping || exit 1"
-      interval: 5s
-      timeout: 5s
-      retries: 30
+      <<: *healthcheck-slow-start
 
   opensearch:
     healthcheck:
       test: "curl --fail opensearch:9200/_cat/health >/dev/null || exit 1"
-      interval: 5s
-      timeout: 5s
-      retries: 30
+      <<: *healthcheck-slow-start
 
   #elasticsearch:
   #  healthcheck:
   #    test: "curl --fail elasticsearch:9200/_cat/health >/dev/null || exit 1"
-  #    interval: 5s
-  #    timeout: 5s
-  #    retries: 30
+  #    <<: *healthcheck-slow-start
 
   rabbitmq:
     healthcheck:
       test: "rabbitmq-diagnostics -q ping"
-      interval: 5s
-      timeout: 5s
-      retries: 30
+      <<: *healthcheck-slow-start
 
   mailcatcher:
     healthcheck:
       test: "wget --no-verbose --tries=1 --spider 127.0.0.1:1080 || exit 1"
+      <<: *healthcheck-defaults