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:
- webHow it works
- Each service gets its own container inside the same server.
- Top-level
envis merged into every service; service-levelenvoverrides it. - A service named
webis treated as the primary for routing defaults. internal: truekeeps a service off the public network — only sibling services can reach it.depends_onis 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_URLApplication code must read the bound variable and tolerate dependency restarts.
See Set up your repository, Managed databases, and Variables and secrets.