Run stage and prod on a Mac
The demo Project (adops init --demo) ships three Environments that all run against local Docker
databases: dev, stage and prod. Each one has its own Warehouse database (warehouse,
warehouse_stage, warehouse_prod) and its own Reverse Sync target (shop_dev, shop,
shop_prod). This guide shows how to run stage and prod by hand on a Mac, and how to start the
Server so their Schedules run there too.
Setting up Promotion through GitHub (self-hosted runners, the prod approval) is a separate task: see Promotion setup.
Before you start
- A Postgres Warehouse. The demo uses one. A Server whose Warehouse is a DuckDB file must run on
Linux: the Warehouse lock on a DuckDB file is a file lock (
flock), and a file lock is not reliably shared between macOS and a container through a folder mount, so two runs could write to the same DuckDB file at once. The Postgres Warehouse lock lives inside Postgres, so it works the same on a Mac. For a DuckDB Server, use a Linux machine of at least the Minimum DuckDB Server size (2 vCPUs, 8 GB memory, 20 GB disk; see Promotion setup: Before you start). To try one, Run a trial Server on AWS makes such a machine. - A Docker runtime that supports host networking. The Server's containers use
network_mode: hostto reach the databases on127.0.0.1.- OrbStack: supports host networking with no extra setting. This is what was tried (see Recorded trial).
- Docker Desktop 4.34 or later: turn on Settings > Resources > Network > Enable host networking, then restart Docker Desktop. This should work, but it has not been tried.
adopsinstalled on the Mac, for running Pipelines by hand.
Step 1 — Start the databases with prod's databases created
The databases create warehouse_prod and shop_prod only the first time their volumes are made.
If you started the demo before it had a prod Environment, recreate the volumes. This deletes the
demo data in them, and the seed scripts load it again:
docker compose down -v
docker compose up -d --wait
Step 2 — Run Pipelines in stage or prod
adops run shop_sync --env stage
adops run shop_sync --env prod
adops run --all --env prod
A prod run writes only to warehouse_prod and shop_prod. The dev and stage databases are left as
they were.
The demo's prod points at the local Docker databases. Before you point it at a real prod machine,
edit host, port and database under prod: in adops.yaml.
The Assistant stays on dev and Branch Environments. Never ask it to run --env stage or
--env prod. Run those commands yourself, or let the Server and Promotion run them.
Step 3 — Start the Server for stage or prod
The Server runs each Pipeline on its Schedule, in the one Environment named by ADOPS_ENVIRONMENT
in .env (stage by default). Only Pipelines with a schedule: line run. For a quick try, add
schedule: "* * * * *" (every minute) as the first line of pipelines/shop_sync.yaml.
The Server reads the Project from a current link inside the Project folder, the layout a Promotion
deploy uses (see Promotion setup). Make one that
points at a copy of the Project, with .env and .adops/ shared:
mkdir -p .adops releases/local
rsync -a --exclude=/releases --exclude=/current --exclude=/.env --exclude=/.adops --exclude=/.git ./ releases/local/
ln -s ../../.env releases/local/.env
ln -s ../../.adops releases/local/.adops
ln -s releases/local current
The Server reads Pipeline files from current/, so edit them there (for example
current/pipelines/shop_sync.yaml) while it runs.
Build the Server image once, then start it:
docker compose --profile server build
docker compose --profile server up -d --wait --no-build
If you work from an adops source checkout, or the adops version in Dockerfile is not on the package
index yet, build the image from a wheel instead. Copy the wheel into the Project folder first, and
build both Server services this way. A plain up without --no-build would rebuild the
webserver without the wheel and fail:
docker compose --profile server build --build-arg ADOPS_PACKAGE=/build/adops-0.3.1-py3-none-any.whl
Use the file name uv build --wheel printed: the 2026-11-28 trial built adops-0.3.1-py3-none-any.whl.
Check that the container sees the same current as the Mac. The two commands must print the same
releases/local, and again after any later switch of the link (a Promotion deploy switches it to
releases/<commit>):
readlink current
docker compose --profile server exec dagster_daemon readlink /project/current
If the container prints an old folder or nothing, the Docker runtime is not passing link changes through the folder mount. This check has not been tried on OrbStack or Docker Desktop yet.
Open the Dagster page at http://127.0.0.1:3000. If another program already uses port 3000, set
DAGSTER_WEBSERVER_PORT in .env to a free port before starting the Server.
Step 4 — Switch the Server between stage and prod
Run one Server per machine at a time. Stage and prod Servers use the same Dagster page port and the
same Dagster metadata database (DAGSTER_PG_DB). To switch:
-
In the Dagster page, check that no run is in progress.
-
Stop the Server cleanly:
docker compose --profile server stop dagster_daemon dagster_webserver -
In
.env, setADOPS_ENVIRONMENT=prod(or back tostage). -
Start it again:
docker compose --profile server up -d --wait --no-build
.env decides which Environment this machine's Server runs. Change it only when you mean to switch,
and set it back when you are done with prod, so the next start does not quietly run prod.
What the trial showed after switching from stage to prod:
- Run history is shared. The prod Server's Dagster page listed stage's earlier scheduled run,
and the
adops run --env prodrun made by hand, next to prod's own run. No label says which Environment a run belongs to. Read run history knowing it mixes both. - The Schedule carried over.
shop_sync_schedulestayed on, in the state the code declares, and the prod Server ran it at the next minute without any action. The on/off state lives in the shared database, so turning a Schedule off while on stage should leave it off for prod too. The trial did not try this. - Recovery left stage's runs alone. On start,
adops server-recoverprinted onlyalerts are off: no webhook URL is set, and stage's runs stayedSUCCESS. That is because the stage Server was stopped cleanly with no run in progress.server-recovermarks every run leftSTARTINGorSTARTEDas failed, whichever Environment made it. So if the stage Server crashed mid-run and you started it as prod, it would mark stage's run failed and send the alert for prod. Stopping cleanly avoids this.
If you want separate run history per Environment, give each Environment its own Dagster database:
create a second database in the dagster_meta container and change DAGSTER_PG_DB in .env when
you switch. adops does not set this up for you.
Move a Server to another Warehouse
To point stage or prod at another Warehouse (another Postgres host or database, or Postgres to
DuckDB), edit that Environment's warehouse: block in adops.yaml and deploy it as usual. Changing
only user: or password_env: is not a move.
On the next run of that Environment, adops sees that its dlt State Folder .adops/dlt/<env>
belongs to the old Warehouse. It renames the folder to .adops/dlt/<env>.moved-<UTC time>, prints
one line, and starts dlt state afresh:
Warehouse changed for stage: old dlt state kept at .adops/dlt/stage.moved-20261202T103000123456Z; starting fresh
Without this, dlt would keep the old Warehouse's Incremental cursors and the new Warehouse would
miss rows and tables. A Branch's folder (.adops/dlt/br_<branch>) follows stage's Warehouse the
same way.
Expect the first runs after the move to do more work:
- Every Incremental table loads again from the start, because its cursor starts afresh.
- The next deploy run reruns every Step, because the change to
adops.yamlchanges the Settings Marker.
adops never deletes the moved-aside folder. It holds the old Warehouse's dlt state, so you can move
back by stopping the Server, renaming .adops/dlt/<env>.moved-<UTC time> back to .adops/dlt/<env>
and restoring the old warehouse: block. Once you are sure you will not go back, delete the
.moved- folder by hand.
Back up and restore
To keep this Server's run history, Load Records, Step Fingerprints and Incremental state through a lost disk or a move to another folder, see Back up and restore a Server. It was tried on this Mac setup.
Freshness alerts
A Server can alert when a table stops loading. Add stale_after to a Sync table in a Pipeline
that has a Schedule:
schedule: "daily at 02:00"
name: shop_sync
steps:
- name: sync_shop
source: shop
tables:
- name: customers
stale_after: 26h
stale_after takes minutes, hours or days (30m, 6h, 2d). On a Pipeline with no Schedule,
adops validate, adops run and the Server refuse it with stale_after needs a Schedule on this Pipeline. It is not the freshness Check: that Check runs inside a run and fails the Step when a
column's newest value is too old. stale_after is checked by the Server between runs, so it also
catches a Schedule that stopped or was paused.
The Server's adops_freshness_check sensor checks every 60 seconds. To change that, set
ADOPS_FRESHNESS_CHECK_SECONDS in .env (a whole number of seconds, 1 or more) and restart the
Server. When a table has not been Loaded within its limit, the alert webhook gets one Stale Alert:
Pipeline shop_sync table customers in Environment stage is stale: last Loaded 2026-11-29T02:00:41+00:00, Stale Limit 26h
Nothing more is sent while the table stays stale. Once it is Loaded again, one Recovery Notice follows:
Pipeline shop_sync table customers in Environment stage has recovered: last Loaded 2026-11-30T02:00:39+00:00, Stale Limit 26h
Things to know:
- A table counts as Loaded when its Sync Step passes its Checks in a stage or prod run, even
with 0 rows. A deploy that reruns nothing (every Step
unchanged in <env>) does not count, so it does not reset the clock. - On a DuckDB Warehouse an alert can be late by up to one run attempt. DuckDB lets only one
process open the file, so a check that finds a run holding the Warehouse lock skips that tick
(
skipped: a run holds the Warehouse lock) and the next free tick sends the alert. - A Server that is down sends no alerts. The check runs on the Server, so it cannot report the Server itself being stopped.
- Pausing carries across stage and prod. Like a Schedule, the sensor's on/off state lives in the
shared Dagster database, so pausing
adops_freshness_checkon stage leaves it paused for prod. What each table was alerted for lives in each Environment's own Warehouse (adops._adops_freshness_state), so stage and prod never share it. - Each stage and prod run also writes Load Records (start and finish time, outcome and rows loaded
per Step and table) to
adops._adops_load_historyin that Environment's Warehouse.
Dead run alerts
A run you start by hand (docker compose run --rm adops run ... or adops backfill) holds a Run
Liveness Lock in the Server's Dagster database while its process lives. If that process is killed,
the Server's adops_dead_run_check sensor marks the run failed, so the Pipeline's Schedule runs
again, and the alert webhook gets one message:
Pipeline shop_sync in Environment stage: a run whose process stopped was marked failed
The Environment is the one the run was started for. The sensor checks every 60 seconds; to change
that, set ADOPS_DEAD_RUN_CHECK_SECONDS in .env (a whole number of seconds, 1 or more) and
restart the Server. adops server-recover also leaves such a run alone while its process still
holds the lock.
Run history retention
The Server keeps 30 days of Dagster run history. Every hour its adops_history_purge sensor
deletes runs that finished more than 30 days ago, with their event logs and their Step output in
.adops/dagster/compute_logs, and the Schedule ticks older than that. A run is as old as its end,
so a backfill that started 40 days ago and finished yesterday is kept. A run still queued or
running is never deleted. Each hour deletes at most 200 runs, so a first purge of a long history
spreads over several hours. The purge starts no Dagster run.
To keep more or less, set ADOPS_RUN_HISTORY_DAYS in .env (a whole number of days, 1 or more)
and restart the Server. Deleted runs come back only from a Server backup. The Warehouse is not
touched: Load Records, Step Fingerprints and Incremental state stay.
Telemetry (OpenTelemetry and Grafana)
Stage and prod runs can send a trace per run, Step metrics and their result lines over
OpenTelemetry (OTLP over HTTP). The demo Project has an optional grafana profile with an OTel
collector and Grafana (with Tempo, Loki and Prometheus) to view them on this Mac.
-
Check free disk first. The Grafana image is over 1 GB:
df -h / -
Turn sending on: in
.env, uncomment this line.OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 -
Start the collector and Grafana:
docker compose --profile grafana up -d -
Run a Pipeline in stage (
adops run shop_sync --env stage), or let the Server run it. Open Grafana athttp://127.0.0.1:3001(ADOPS_GRAFANA_PORTin.env) and pick the adops runs dashboard. Traces are under Explore → Tempo, result lines under Explore → Loki.
Things to know:
- Only stage and prod runs send anything. dev and Branch runs, and runs that never started, send nothing.
- A retried scheduled run gives one trace per attempt.
- To filter or forward, edit
otel/collector.yaml. It has a commented example that drops an attribute, and its exporter can point at your own backend instead of Grafana. Restart withdocker compose --profile grafana restart otel_collector. - Grafana has no login here. Anyone who can reach its port is an admin, so the profile
publishes both ports on
127.0.0.1only. Reach it from another machine through an SSH tunnel. - A stopped collector does not fail a run. adops sends nothing and carries on; turn sending off by commenting the line out again.
Recorded trial
Tried on 2026-11-23 on a Mac (macOS 27.2.1, Apple silicon) with OrbStack 2.2.5, Docker Engine 29.8.2. Docker Desktop was not tried.
Commands, run from a fresh demo Project (<repo> is an adops source checkout):
cd <repo> && uv build --wheel --out-dir dist
adops init shop --demo && cd shop
cp .env.example .env
cp <repo>/dist/adops-0.1.0-py3-none-any.whl .
docker compose down -v
docker compose up -d --wait
adops run shop_sync --env prod
# Port 3000 was taken on this Mac, so the trial used 3300.
sed -i '' 's/^DAGSTER_WEBSERVER_PORT=.*/DAGSTER_WEBSERVER_PORT=3300/' .env
printf 'schedule: "* * * * *"\n' | cat - pipelines/shop_sync.yaml > p.tmp && mv p.tmp pipelines/shop_sync.yaml
docker compose --profile server build --build-arg ADOPS_PACKAGE=/build/adops-0.1.0-py3-none-any.whl
docker compose --profile server up -d --wait --no-build # ADOPS_ENVIRONMENT=stage
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:3300/server_info
docker compose --profile server stop dagster_daemon dagster_webserver
sed -i '' 's/^ADOPS_ENVIRONMENT=.*/ADOPS_ENVIRONMENT=prod/' .env
docker compose --profile server up -d --wait --no-build # ADOPS_ENVIRONMENT=prod
docker compose --profile server down -v --rmi local
What was observed:
| Check | Result |
|---|---|
adops run shop_sync --env prod from the Mac |
wrote: inserted 20, updated 0, deleted 0 and Pipeline shop_sync passed in Environment prod.; shop_prod.customer_stats held 20 rows |
Mac browser/curl to the webserver on 127.0.0.1:3300 |
HTTP 200 within about 20 seconds after up returned |
Host-networked containers reach Postgres published on 127.0.0.1 |
yes: the daemon read and wrote the Dagster database on 15434 and the Warehouse and shop on 15433/15432 |
| Stage Server, scheduled run | run 430c7981-8887-4ea2-87b3-3a2397620338: SUCCESS; shop.customer_stats held 20 rows |
| Switch to prod | clean stop, .env edited, restart; server-recover marked nothing |
| Prod Server, scheduled run | shop_prod.customer_stats was emptied before the switch; run 7ccea034-52a4-43f8-b3f4-9d705661fdf5: SUCCESS, and it held 20 rows again |
| Prod Dagster page run list | 7ccea034 (prod, scheduled), 430c7981 (stage, scheduled), d247c422 (the hand-run prod run), with no Environment label |
No blocker was found.