Skip to content

Healthchecks

slidict-ai-team[bot] edited this page Nov 28, 2026 · 1 revision

Healthchecks

healthcheck: lets wip up wait until a sidecar container is actually ready before starting the next dependency or the primary container. It works in both mode: container (dependencies.<name>.healthcheck in wip.yml) and mode: compose-native (services.<name>.healthcheck in compose.yml), using the same parser and polling loop.

Declaring a healthcheck

In wip.yml (mode: container):

dependencies:
  db:
    image: postgres:16
    env:
      POSTGRES_PASSWORD: password
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 2s
      timeout: 5s
      retries: 10
      start_period: 3s

In compose.yml (mode: compose-native):

services:
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: password
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]
      interval: 2s
      timeout: 5s
      retries: 10
      start_period: 3s
  app:
    image: myapp:dev
    depends_on:
      db:
        condition: service_healthy

Keys and defaults

Key Required Default Format
test yes (unless block is null) — string or non-empty array starting with CMD, CMD-SHELL, or NONE
interval no 1 (1s) positive number of seconds or Compose duration string
timeout no 1 (1s) positive number of seconds or Compose duration string
retries no 3 positive whole number (duration strings are rejected)
start_period no 0 (0s) non-negative number of seconds or Compose duration string

Unrecognized keys inside healthcheck: fail at load time.

test forms

Form Executed in the container as
"pg_isready -U postgres" sh -c "pg_isready -U postgres"
["CMD-SHELL", "pg_isready -U postgres"] sh -c "pg_isready -U postgres" (must take exactly one command string)
["CMD", "pg_isready", "-U", "postgres"] pg_isready -U postgres directly, without a shell (needs at least one argument)
"NONE" or ["NONE"] or healthcheck: null disables the healthcheck (same as omitting healthcheck:)

Duration syntax

interval, timeout, and start_period accept either a plain number of seconds (2, 0.5) or a Compose duration string made of concatenated <number><unit> segments with no separator:

Unit Meaning
h hours
m minutes
s seconds
ms milliseconds
us microseconds

Examples: "10s", "1m30s", "500ms", "1h30m". Anything not fully accounted for by valid segments is rejected at load time. retries is always a count, never a duration.

How wip up waits

After starting each sidecar, wip up runs wslc exec <name> <test...> with timeout enforced per probe:

wip: waiting for dependency 'db' to become healthy
wip: dependency 'db' is healthy
  • Wait scope: wip up waits on every sidecar that declares healthcheck:, even if no depends_on condition mentions service_healthy. The primary container is started last and is not healthcheck-polled by wip up.
  • start_period grace: probes still run during start_period (so an early pass succeeds immediately), but failures while start_period has not yet elapsed do not count against retries.
  • Retries and timeout: once start_period has passed, a failing or timed-out probe increments the failure count and sleeps interval seconds before retrying. Once failures exceed retries, wip up aborts and prints the last non-empty line of probe output (stdout/stderr):
dependency 'db' did not become healthy after 4 attempt(s) (last check exited 1): /var/run/postgresql:5432 - no response
dependency 'db' did not become healthy after 4 attempt(s) (last check timed out)

With depends_on: condition: service_healthy

Under mode: compose-native, depends_on accepts condition: service_healthy alongside service_started. If a service specifies condition: service_healthy for a target that has no healthcheck: configured, wip rejects the file at load time instead of waiting on nothing. See Compose Depends On.

Related

Clone this wiki locally