Skip to content

Commit

Permalink
fix: reduce idle cpu usage with longer health check interval
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Sep 6, 2023
1 parent 8455661 commit 63790a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions internal/db/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + `
Expand Down
36 changes: 18 additions & 18 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}},
},
Expand Down Expand Up @@ -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": {}},
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 63790a1

Please sign in to comment.