Skip to main content

Dependencies

Runix supports process dependencies — a process can wait for other processes to be running before starting.

Configuration​

processes:
postgres:
entrypoint: postgres
priority: 100
health_check:
type: tcp
tcp_endpoint: localhost:5432

redis:
entrypoint: redis-server
priority: 90
health_check:
type: tcp
tcp_endpoint: localhost:6379

api:
entrypoint: ./cmd/api
depends_on: [postgres, redis]
priority: 50

worker:
entrypoint: worker.py
depends_on: [postgres, redis, api]
priority: 10

Startup Ordering​

When starting from a config file, Runix resolves dependencies using topological sort:

Start order: postgres → redis → api → worker

Resolution Algorithm​

  1. Build a dependency graph from depends_on fields
  2. Detect circular dependencies (rejected with error)
  3. Perform topological sort (Kahn's algorithm)
  4. Within each level, sort by priority (higher priority starts first)
  5. Start processes in order, waiting for each dependency to reach running state

Priority​

Priority is used as a tiebreaker when processes have no dependency relationship:

PriorityBehavior
Higher valueStarts first
Default (0)Starts last among peers
processes:
critical-service:
priority: 100 # Starts first
standard-service:
priority: 50 # Starts second
low-priority:
priority: 0 # Starts last

Circular Dependency Detection​

Circular dependencies are detected at config validation time:

processes:
a:
depends_on: [b]
b:
depends_on: [a]
Error: circular dependency detected: a → b → a

Runtime Behavior​

When a process has dependencies:

  1. Runix checks if all dependencies are in running state
  2. If not, the process waits (with context cancellation support)
  3. Once all dependencies are running, the process starts
  4. If a dependency crashes and doesn't recover, the dependent process stays in created state

What's Next​