Create scripts/run-detached.sh #84

Closed
opened 2026-01-17 21:53:46 +00:00 by lmiranda · 0 comments
Owner

Overview

Create a script to run Docker Compose services in detached mode with health check verification.

Acceptance Criteria

  • Create scripts/run-detached.sh
  • Run docker compose up -d to start services
  • Implement health check loop waiting for services to become healthy
  • Timeout after reasonable period (e.g., 60 seconds)
  • Exit with appropriate codes (0 = success, 1 = timeout/error)
  • Include usage comments at top
  • Use set -euo pipefail for bash safety
  • Make script executable

Technical Notes

Example implementation:

#!/usr/bin/env bash
# Usage: scripts/run-detached.sh
# Start docker compose services and wait for health checks.
# Exits 0 on success, 1 on timeout.

set -euo pipefail

TIMEOUT=60
INTERVAL=2

echo "Starting services..."
docker compose up -d

echo "Waiting for services to be healthy..."
elapsed=0
while [ $elapsed -lt $TIMEOUT ]; do
    if docker compose ps | grep -q "(healthy)"; then
        echo "Services healthy after ${elapsed}s"
        exit 0
    fi
    sleep $INTERVAL
    elapsed=$((elapsed + INTERVAL))
done

echo "ERROR: Timeout after ${TIMEOUT}s waiting for healthy services"
docker compose ps
exit 1

Labels

  • Type/Feature
  • Priority/Medium
  • Complexity/Simple
  • Component/Infra

Phase: 3 - Operational Scripts

## Overview Create a script to run Docker Compose services in detached mode with health check verification. ## Acceptance Criteria - [ ] Create `scripts/run-detached.sh` - [ ] Run `docker compose up -d` to start services - [ ] Implement health check loop waiting for services to become healthy - [ ] Timeout after reasonable period (e.g., 60 seconds) - [ ] Exit with appropriate codes (0 = success, 1 = timeout/error) - [ ] Include usage comments at top - [ ] Use `set -euo pipefail` for bash safety - [ ] Make script executable ## Technical Notes Example implementation: ```bash #!/usr/bin/env bash # Usage: scripts/run-detached.sh # Start docker compose services and wait for health checks. # Exits 0 on success, 1 on timeout. set -euo pipefail TIMEOUT=60 INTERVAL=2 echo "Starting services..." docker compose up -d echo "Waiting for services to be healthy..." elapsed=0 while [ $elapsed -lt $TIMEOUT ]; do if docker compose ps | grep -q "(healthy)"; then echo "Services healthy after ${elapsed}s" exit 0 fi sleep $INTERVAL elapsed=$((elapsed + INTERVAL)) done echo "ERROR: Timeout after ${TIMEOUT}s waiting for healthy services" docker compose ps exit 1 ``` ## Labels - Type/Feature - Priority/Medium - Complexity/Simple - Component/Infra ## Phase: 3 - Operational Scripts
Sign in to join this conversation.