From 63790a1bd43bee06f82c4f510e709925526a4daa Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 6 Sep 2023 15:28:04 +0800 Subject: [PATCH] fix: reduce idle cpu usage with longer health check interval --- internal/db/start/start.go | 4 ++-- internal/start/start.go | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 404327aa2..aa7fe635d 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -60,9 +60,9 @@ func NewContainerConfig() container.Config { }, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "pg_isready", "-U", "postgres", "-h", "localhost", "-p", "5432"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && docker-entrypoint.sh postgres -D /etc/postgresql ` + initialSchema + ` diff --git a/internal/start/start.go b/internal/start/start.go index 6f3ceee2b..f154796a9 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -170,9 +170,9 @@ EOF "--tries=1", "--spider", "http://localhost:9001/health"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, ExposedPorts: nat.PortSet{"9000/tcp": {}}, }, @@ -254,9 +254,9 @@ EOF `}, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "curl", "-sSfL", "--head", "-o", "/dev/null", "http://localhost:4000/health"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, StartPeriod: 10 * time.Second, }, ExposedPorts: nat.PortSet{"4000/tcp": {}}, @@ -495,9 +495,9 @@ EOF ExposedPorts: nat.PortSet{"9999/tcp": {}}, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9999/health"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, start.WithSyslogConfig(container.HostConfig{ @@ -573,9 +573,9 @@ EOF ExposedPorts: nat.PortSet{"4000/tcp": {}}, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "bash", "-c", "printf \\0 > /dev/tcp/localhost/4000"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, start.WithSyslogConfig(container.HostConfig{ @@ -640,9 +640,9 @@ EOF Healthcheck: &container.HealthConfig{ // For some reason, localhost resolves to IPv6 address on GitPod which breaks healthcheck. Test: []string{"CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:5000/status"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, start.WithSyslogConfig(container.HostConfig{ @@ -669,9 +669,9 @@ EOF }, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "imgproxy", "health"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, container.HostConfig{ @@ -710,9 +710,9 @@ EOF }, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "node", "-e", "require('http').get('http://localhost:8080/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, container.HostConfig{ @@ -746,9 +746,9 @@ EOF }, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "node", "-e", "require('http').get('http://localhost:3000/api/profile', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, container.HostConfig{ @@ -782,9 +782,9 @@ EOF }, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "bash", "-c", "printf \\0 > /dev/tcp/localhost/6432"}, - Interval: 2 * time.Second, + Interval: 10 * time.Second, Timeout: 2 * time.Second, - Retries: 10, + Retries: 3, }, }, container.HostConfig{