autodisc
Guides

Multi-Service Deployments

Run multiple processes in one project with services.

Most Autodisc projects run a single process per server. If your project has more than one — say a web app plus a background worker — define them under services: in autodisc.yml.

Example

env:
  NODE_ENV: production

services:
  web:
    run: node dist/server.js
    port: 3000
    routes:
      - example.com

  worker:
    run: node dist/worker.js
    internal: true
    depends_on:
      - web

How it works

  • Each service gets its own container inside the same server.
  • Top-level env is merged into every service; service-level env overrides it.
  • A service named web is treated as the primary for routing defaults.
  • internal: true keeps a service off the public network — only sibling services can reach it.
  • depends_on is a list of service names that should start first.

See Configuration for the full field reference.

Add managed data resources

Do not run PostgreSQL or Redis as an ordinary application service. Create the managed resource in the intended project environment and bind its connection_url output to each consuming service:

services:
  api:
    run: node dist/api.js
    port: 3000

  worker:
    run: node dist/worker.js
    internal: true

resources:
  customer-data:
    type: postgresql
    class: shared-small

bindings:
  - source: resource.customer-data.connection_url
    target: service.api.environment.DATABASE_URL
  - source: resource.customer-data.connection_url
    target: service.worker.environment.DATABASE_URL

Application code must read the bound variable and tolerate dependency restarts.

See Set up your repository, Managed databases, and Variables and secrets.

On this page