GoDoxy
Advanced Topics

Idle Sleep

Automatically sleep idle containers and wake them on traffic. Saves resources for infrequently used services

Overview

GoDoxy puts containers to sleep after a period of inactivity and wakes them automatically when traffic arrives. This feature is ideal for development environments, staging servers, or services with unpredictable usage patterns.

Supported Platforms

  • Docker
  • Podman through its Docker-compatible API
  • Proxmox LXCs

Supported Protocols

ProtocolDescription
HTTPStandard web traffic
TCPGeneric TCP connections
UDPGeneric UDP connections

Quick Reference

PropertyDescriptionDefaultRequired
idle_timeoutInactivity before sleepDisabledYes
wake_timeoutWait time for wake3mNo
stop_methodContainer stop methodstopNo
stop_timeoutStop command timeout1mNo
stop_signalSignal for stop/killDocker defaultNo
start_endpointWake trigger endpointAnyNo
no_loading_pageDisable wake pagefalseNo

How It Works

Sleep Behavior

  1. Container receives no traffic for idle_timeout duration
  2. GoDoxy executes stop_method on the container
  3. Container dependencies are stopped in order unless another running watcher directly depends on them
  4. Traffic to the route triggers wake-up sequence

Wake Behavior

  1. Request arrives for sleeping route
  2. For an HTML navigation, GoDoxy returns the loading page immediately and starts one background wake operation
  3. Dependencies start first (if configured)
  4. Main container starts
  5. The loading page receives startup progress over server-sent events
  6. GoDoxy waits up to wake_timeout for readiness, then the loading page refreshes into the active service

Non-HTML requests, and all requests when no_loading_page is enabled, wait for wake-up so GoDoxy can proxy the original request after the service becomes ready. Canceling an HTML navigation after its loading page has been returned does not cancel the shared wake operation.

Idle start, ready, sleep, pause, and error transitions appear in the WebUI Live Activity feed.

Dependency Management

Containers with depends_on wake their dependencies first, including transitive dependencies. When a container sleeps, its dependencies also sleep unless another running watcher directly depends on them. Shared dependencies remain available until their last running dependent sleeps. Sleeping dependents do not keep dependencies running; traffic wakes the required dependency chain again.

Podman Compose dependencies are discovered automatically through the native Podman inspect API, including dependencies of services without their own idle timeout. This works through a direct provider connection or an agent. When using GoDoxy's socket proxy, enable CONTAINERS and use a version that allows native Podman GET inspect requests.

proxy.depends_on overrides automatic discovery. Podman's native API does not retain Compose readiness conditions, so automatically discovered dependencies use service_started. For health-based readiness, set an explicit label such as proxy.depends_on: redis:service_healthy. If native inspection fails, GoDoxy logs a warning and keeps the routes; restore API access and reload to discover the dependencies.

Do not set idle_timeout on dependency containers.

Condition Types

Control when dependencies are considered ready:

ConditionDescription
service_startedDependency process started
service_healthyDependency healthcheck passes

Docker Compose Example

# Without conditions (implies service_started)
depends_on:
  - redis
  - postgres

# With explicit conditions
depends_on:
  redis:
    condition: service_healthy
  postgres:
    condition: service_started

Label Syntax

labels:
  proxy.depends_on: redis:service_healthy,postgres:service_started

Docker Configuration

Enable idle sleep by adding labels to your container:

services:
  app:
    image: nginx:latest
    container_name: my-app
    labels:
      # Required
      proxy.idle_timeout: 1h30s
      # Optional
      proxy.wake_timeout: 30s
      proxy.stop_method: stop
      proxy.stop_timeout: 10s
      proxy.stop_signal: SIGINT
      proxy.start_endpoint: /start
      proxy.no_loading_page: true
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy

  redis:
    image: redis:alpine
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  postgres:
    image: postgres:16
    # Healthcheck configured via GoDoxy health monitoring

Proxmox LXC Configuration

See Proxmox Integration for detailed configuration options.

Sleep and Wake Notifications

Notifications are off by default. Configure providers under providers.notification, then opt an idle-sleep route in using idlewatcher.notify:

# Add inside the route's existing idlewatcher configuration
notify:
  to: [gotify, ntfy] # Names under providers.notification

Omitting the notify block inherits the global notification configuration, or stays silent when none is configured. notify: {} opts in and inherits global targets when to is omitted. If global targets are also omitted, notifications go to all current providers at send time.

To enable notifications for all routes that use idle sleep, add this to config.yml:

defaults:
  idlewatcher:
    notify:
      to: [gotify] # Use notify: {} to broadcast instead

Use notify: {} instead of the target list to send to all current providers. A route can select different providers with to or opt out with notify: {to: []}, overriding global targets. Global notify: {to: []} also disables notifications, but a route can override it with a non-empty target list. Global notification defaults do not enable idle sleep.

For Docker, use proxy.idle_notify_to: gotify,ntfy to select providers. A missing label inherits the global notification configuration. To broadcast, configure global notify: {}. proxy.idle_timeout is still required. An explicit empty string opts a container out, even when global notifications are configured:

labels:
  proxy.idle_timeout: 30m
  proxy.idle_notify_to: ""

These info-level notifications report sleep and wake transitions, with pause wording for paused containers. They do not report readiness or errors, and dependency-only containers do not send them. Initial observation, configuration reload, and watcher teardown do not send notifications.

Property Reference

Core Properties

PropertyDescriptionDefaultAccepted Values
idle_timeoutInactivity before sleepDisabledDuration (1h30s, 15m)
wake_timeoutWait for wake completion3mDuration
start_endpointWake trigger pathAnyRelative URI

Stop Control

PropertyDescriptionDefaultAccepted Values
stop_methodContainer stop actionstopstop, pause, kill
stop_timeoutStop command wait time1mDuration
stop_signalSignal for stop/killDocker defaultSIGINT, SIGTERM, SIGQUIT, SIGKILL (with or without SIG prefix)

With stop_method: kill, GoDoxy waits up to stop_timeout for the runtime to confirm that the container stopped or paused before stopping its dependencies. A signal such as SIGHUP may leave the container running. In that case, the operation times out and its dependencies remain running.

UI Options

PropertyDescriptionDefaultValues
no_loading_pageDisable wake loading pagefalseboolean

Duration Format

Use standard duration notation:

UnitDescriptionExample
sSeconds30s
mMinutes15m
hHours1h
h m sCombined1h30m15s

Examples

Development Environment

services:
  dev-api:
    image: myapp/api:latest
    labels:
      proxy.idle_timeout: 30m
      proxy.wake_timeout: 60s
      proxy.stop_method: kill
      proxy.stop_timeout: 5s
    depends_on:
      dev-db:
        condition: service_healthy
  dev-db:
    image: postgres:16
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 3s

Staging with Specific Wake Endpoint

services:
  staging-app:
    image: myapp/staging:latest
    labels:
      proxy.idle_timeout: 2h
      proxy.start_endpoint: /api/wake
      proxy.no_loading_page: false

Best Practices

  1. Use healthchecks with service_healthy condition for reliable dependencies
  2. Set appropriate timeouts based on your service startup time
  3. Test wake behavior before deploying to production
  4. Monitor container logs during initial setup
  5. Use consistent stop signals that match your application

On this page