Globetrotter docsversion 0.3.0 · 2026-12-04

Deploy and operate

On this page
  1. Try it as a server
  2. The processes
  3. What a server refuses to start without
  4. Environments and settings
  5. Health and readiness
  6. Logs
  7. Traces and metrics
  8. Scaling
  9. Stopping
  10. A rollout
  11. Backups
  12. Checks to run in CI
$ cd backend && cp .env.example .env     # fill in the empty secrets
$ docker compose up --build

npx globetrotter dev starts everything for a laptop. A server runs the same pieces, each on its own: in the image, or by hand as below.

sync writes what a server needs beside the code, under backend/ (Python target). Nothing is built or started for you: docker compose up --build is yours to run.

File Is
Dockerfile, .dockerignore One image, uv-based and multi-stage, Python as the workspace's requires-python, a user that is not root, uv sync --frozen --no-dev --all-packages. Its command is the API; compose gives each other process its own. Its HEALTHCHECK calls /ready.
compose.yaml migrate (once), api, and relay, worker and scheduler only when the design has them; a database container per Postgres or MySQL store, Redis for a Redis store or the worker's broker, a volume for SQLite and for files. Each store's URL is built for the container, or taken from .env. With tenancy.rls, a second database role, <app>_app (DB_APP_USER, DB_APP_PASSWORD), is made on the database's first start with no superuser and no BYPASSRLS: migrate runs as the owner, api, relay, worker and scheduler as that role (<STORE>_APP_URL overrides its address), so the row-level security policy binds what serves. Bound, the scheduler's jobs (outside any request), a worker step whose event carries no organisation, and the API's staffSeesAll with no organisation named see no rows of the guarded (scope: rows) tables: name an organisation, set app.org, or run that process as a BYPASSRLS role (<STORE>_URL). In production the API serves nothing until its role has been checked, and waits up to 30 seconds for the database to do it.
.env.example Every variable the generated code reads for this design, grouped, a comment each, secrets empty; then the few only compose reads (the database containers' user, password and name). Rewritten on each sync.
README.md Which packages are generated and which is yours, how to run, test, migrate and build, the environment table.
ci/github-actions.yml uv sync, ruff, pyright, migrate on SQLite (a database container for a store with no SQLite migrations), pytest.
ruff.toml, pyrightconfig.json The lint and type settings the CI uses.

fieldops' database for a laptop is the same compose file, its db service alone (no .env; Postgres 16 on 127.0.0.1:5440):

$ docker compose -f examples/fieldops/backend/compose.yaml up -d db
$ npm run dev:fieldops

API_PORT (default 8000) is the port compose publishes the API on.

A sync writes a missing file and then leaves yours alone (owners in Generated code). The image was built and run once for fieldops (Postgres; transcript): 389 MB, runs as uid 10001, healthy on /ready, stops in under a second, and with no .env it refuses to start (it is never local by itself). The worker, relay and scheduler ran against Redis 7 in the same compose project on 19 November (transcript): fieldops's own flow is inline, so a durable one was run on a scratch copy; /ready stays 200 with Redis down (it names stores only), and they stop in about a second. The rate limit counted in that Redis, with a second API process beside it, and the scheduler sent once, were run on 19 November on a scratch copy (outside compose; the same transcript). Not run: the Rust image, MySQL, or any other design's image.

Try it as a server

Without Docker, on the quickstart's project (sqlite, no sign-in), from backend/:

$ export GLOBETROTTER_ENV=prod GLOBETROTTER_DB_URL=sqlite:////tmp/prod.sqlite
$ uv run python -m my_api_core.migrate
db: applied 0001, 0002
$ HOST=127.0.0.1 PORT=8000 WORKERS=2 .venv/bin/python -m my_api_fastapi
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started parent process [28849]

Without GLOBETROTTER_DB_URL, migrate stops with prod is not one of this backend's environments (local): add it in the studio's Environments (designs/components.prod.json) with the store db's address, or export GLOBETROTTER_DB_URL. What answers, as that server:

Request Answer
GET /health, GET /ready 200, {"status":"ready"}
GET /docs 404
GET /openapi.json 200: the contract is public
GET /metrics 404, until GLOBETROTTER_METRICS=1 and observability.metrics are both on; then Prometheus text (http_requests_total{method="GET",route="/items",status="200"} 1, …). The log then holds one error line, Skipping FastAPI instrumentation due to unexpected middleware stack, and the metrics still answer
GET /items before migrate 503, The database is not ready: db has none applied yet, 0001, 0002 are waiting: in the backend's folder, run GLOBETROTTER_ENV=local uv run python -m my_api_core.migrate. (/ready says the same)
any answer strict-transport-security: max-age=63072000; includeSubDomains, x-content-type-options, x-frame-options, referrer-policy

With GLOBETROTTER_CORS_ORIGINS=https://app.example.com, a request carrying Origin: https://app.example.com is answered with access-control-allow-origin: https://app.example.com and access-control-allow-credentials: true; a preflight OPTIONS answers 200 with the methods GET, POST, PUT, PATCH, DELETE and max-age=600; Origin: https://evil.example gets no access-control-allow-origin. With sign-in on, the same start without GLOBETROTTER_SESSION_SECRET stops with Export GLOBETROTTER_SESSION_SECRET (a long random string): session cookies are signed with it., and with it set the development key and password are refused (401). Not tried here: a port already taken, a Postgres or MySQL store.

The processes

  1. The pages, in frontend/ (when there are pages): npm run build, then npx next start. Set GLOBETROTTER_BACKEND_URL where the app runs: src/proxy.ts sends /api/* there at each request, so one build serves staging and production alike. A build otherwise keeps the address it was built with. sync writes src/proxy.ts once wherever the pages forward /api to a backend and have none; it is yours after your first edit. A middleware.ts of your own is left alone, with a word on what to add to it.
  2. The migrations, in backend/, before each start: GLOBETROTTER_ENV=prod GLOBETROTTER_DB_URL=… uv run python -m <app>_core.migrate. Sync writes them; nothing applies them but this. An environment the project has no designs/components.<env>.json for is refused unless each store's address is given this way.
  3. The service: GLOBETROTTER_ENV=prod GLOBETROTTER_DB_URL=… HOST=0.0.0.0 PORT=8000 WORKERS=4 uv run python -m <app>_fastapi, after uv sync --frozen. With sign-in on it also needs GLOBETROTTER_SESSION_SECRET.
  4. Flows, when the design has any: uv run python -m <app>_core.relay as its own process. With a worker flow, also GLOBETROTTER_BROKER_URL=redis://… uv run python -m <app>_core.worker.
  5. The scheduler, when the design has Schedules: uv run python -m <app>_core.scheduler. It can run beside another (or be restarted) without running a job twice for one due minute: the minute is claimed in the broker's Redis, else in the design's first Redis store with a URL, else in a row of flow_run; keep the jobs safe to repeat all the same (Jobs and schedules). With GLOBETROTTER_BROKER_URL set, the scheduler sends every job to the broker and the jobs run on the worker: run the worker too, or nothing runs them and nothing says so. Without it the scheduler runs the jobs itself.

Rust has one binary, from crates/<app>; its subcommands are migrate, relay, worker and (by hand) audit, outbox, flows, jobs, and no subcommand serves the API. worker relays the events, runs the flows' steps and starts the jobs by their schedules: there is no scheduler process. With GLOBETROTTER_BROKER_URL or a Redis store it claims each due minute there, without one in flow_run. sync writes Dockerfile.rust beside the Python image (its comments name api and migrate, and relay and worker when the design has them; the same image runs <app> relay and <app> worker), and a README.md (README.rust.md beside Python's) with a Processes table of the processes the design needs and an Environment table of what its generated code reads, each marked as set on a server or not (docker run in it names every one that is; what was run is under What a server refuses to start without); see Targets. The Python image has been built (above); the Rust one has not.

sync writes compose.rust.yaml too (the Python target's compose.yaml is never written over; a stub like it, the design's until you edit it): migrate once (<app> migrate), then api (healthcheck on /ready), and relay and worker (no port, healthcheck: { disable: true }) only when the design has them, all from Dockerfile.rust; the database, MySQL and Redis containers as the Python file has them (postgres:16-alpine, mysql:8.4, redis:7, the same healthchecks), a named volume for sqlite (which ties the file to one host) and for files. A variable the table marks as set on a server is ${NAME:?set NAME in .env}, so compose stops before starting. The worker's stop_grace_period is 45 s, over GLOBETROTTER_SCHEDULER_GRACE's 30. Its project is <app>-rust and its API port RUST_API_PORT (8010), so the two files can be run on one machine: each has its own database container and volumes. Its store addresses are read from RUST_<STORE>_URL (RUST_DB_URL), not GLOBETROTTER_<STORE>_URL, so a .env shared with Python's file cannot put both on one database unseen. To share one on purpose, set it to the address Python uses: with Python among the project's targets the Rust migrate then does nothing there and Python's runner applies the migrations (run it first), and the Rust binary serves the database as it left it. Run: docker compose -f compose.rust.yaml up --build. Its YAML was read by docker compose config (nothing started, no image built) on a sqlite design with and without a flow and a job and on fieldops; each service's command was run by hand on a scratch sqlite design (migrate exit 0, /ready 200, relay and worker said their lines). The containers were not run.

The design has Python (one command each) Rust (<app> is the binary)
Nothing but operations python -m <app>_core.migrate, then python -m <app>_fastapi <app> migrate, then <app>
Flows the above, and python -m <app>_core.relay (with a worker flow and a broker: python -m <app>_core.worker too) the above, and <app> worker (<app> relay alone only relays)
Jobs with Schedules the above, and python -m <app>_core.scheduler (with a broker: python -m <app>_core.worker too) the above, and <app> worker
Both relay, scheduler, and with a broker the worker <app> worker, one process for all of it

Python's commands run under uv run. The Rust rows were run on 27 November as separate processes on a scratch sqlite design with a worker flow and a scheduled job: the API, relay and worker each said the line the README's table gives (<app> (rust): http://127.0.0.1:<port>, relay <id>: watching db every 1 s, worker <pid>: ready for … then worker ready: <job> next at HH:MM UTC). Started at one instant on a fresh database (the relay and two workers, ten times) all stayed up. The audit, outbox, flows and jobs tools (with and without --json) were run after a create and a job run: each printed its answer and exited 0; before migrate each said the database is not ready, naming the command, and exited 1. A word that is no command (workr) is refused, exit 2, not taken as a request to serve. A Python scheduler killed with kill -9 mid-job left its flow_run row running, and the Rust worker on the same file marked it abandoned ("1 run was left running by a stopped process: marked abandoned") at its next sweep, after the job's timeout plus ten seconds.

A second migrate started while one runs waits for its lock, and Python's migrate --down goes back (Rust's migrate takes no argument): see Data and migrations.

A design with outside parts needs their settings where it runs: each client's address (clients.<name>.baseUrl in the environment's components file) and key, each webhook's signing secret, and a bucket File's bucket and keys. Outside local the backend names every missing one in one line and does not start. The variables are in the reference.

What a server refuses to start without

Any environment but local stops at start, in one line, when one of these is missing. Read from the Python target's generated settings.py and its start-up.

Needed Where it comes from When
GLOBETROTTER_ENV The variable. Unset is refused unless the project declares an environment named production. Always
Each store's address GLOBETROTTER_<STORE>_URL, else designs/components.<env>.json. An environment with no components file needs the variable. A sqlite store its components file gives no address is a file beside the backend. Always
Every {secret:NAME} the components file names The variable NAME When a setting read at start names one
GLOBETROTTER_CORS_ORIGINS without * A list of origins, or unset Always (local too)
GLOBETROTTER_SESSION_SECRET The variable Session sign-in
GLOBETROTTER_JWT_SECRET The components file's auth.jwt secret, else the variable JWT sign-in
GLOBETROTTER_MAGICLINK_SECRET The variable Magic-link sign-in
GLOBETROTTER_PASSKEY_SECRET The variable Passkey sign-in (Python only)
A way to sign in GLOBETROTTER_API_KEYS (apikey), GLOBETROTTER_PEOPLE (magic link only), the issuer (oidc: auth.oidc.issuer in the components file, or the variable a {secret:NAME} issuer names); a session cookie and a JWT are checked by their signature and need only their secret Sign-in is on, and every way in the design offers is missing its own, and no operation is allowed to anyone. One way in missing while another works starts and says so once on stderr. Python and Rust alike; the worker and scheduler sign nobody in and are never refused for it
GLOBETROTTER_FILE_SECRET The variable The design keeps files (fieldops' photos: pointing fieldops at Postgres as GLOBETROTTER_ENV=pg met exactly this)
A bucket File's bucket and credentials The components file's files.<name>, else AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY A File kept in a bucket
Each client's address and key clients.<name>.baseUrl in the components file, and its key's variable The design has clients
Each webhook's signing secret Its variable The design has webhooks
GLOBETROTTER_APP_ORIGIN An https address, no YOUR_ left (the generated fly.<env>.toml ships a placeholder) A link or code sign-in
GLOBETROTTER_MAIL_FROM An address, no YOUR_ left The design sends email (not with GLOBETROTTER_MAIL=console)
GLOBETROTTER_SMTP_URL, or GLOBETROTTER_MAIL=console console is refused in production; on a stage environment it needs GLOBETROTTER_MAIL_CONSOLE_CODES=1 too, which logs each email whole (codes, links) with a warning A notice goes by email
GLOBETROTTER_FORWARD_SECRET 32 or more characters, the same on the pages' deploy and here GLOBETROTTER_TRUSTED_PROXY=pages+fly

The API, the worker, the relay and the scheduler make the same checks and end with the same line.

GLOBETROTTER_TRUSTED_PROXY says who the addresses behind a proxy are (fly, cloudflare, a CIDR, or pages+fly). Behind a Cloudflare Pages /api forward, Fly sees the function's address for every visitor, so fly makes everyone one caller for every by-address limit (and warns at start without the secret). pages+fly believes the visitor's address the function forwards (X-Gt-Client-Ip) only with the matching X-Gt-Forward-Secret, which globetrotter deploy bakes into the function from GLOBETROTTER_FORWARD_SECRET; a forged header, or a call that skips the function, is counted by Fly's own address. Transcript.

Only in local: the development keys, passwords and secrets, /docs and /redoc, the exception and line in a failed answer, restart on a change, a sqlite file with no components file at all, and backend/.globetrotter/steps.json (each step's last outcome).

What a sign-in type needs, the same on both targets (the rule is written once in core):

Sign-in type Refused at start without Only warned about
session GLOBETROTTER_SESSION_SECRET nothing (no people variable)
jwt GLOBETROTTER_JWT_SECRET nothing (no people variable)
magic link GLOBETROTTER_MAGICLINK_SECRET; GLOBETROTTER_PEOPLE when no other way in works GLOBETROTTER_PEOPLE missing while another way in works
apikey GLOBETROTTER_API_KEYS when no other way in works the same, while another way in works
oidc the issuer when no other way in works the same, while another way in works

Rust refuses the same at start for GLOBETROTTER_ENV, a store's address, a named secret, a star in CORS, clients, webhooks and a bucket's settings. Run on sqlite, without Docker: a production-mode Rust binary with exactly the README's variables started and answered /ready; with the file secret, the database URL or the environment removed, the refusal named it; an apikey design without API keys was refused at start with Set GLOBETROTTER_API_KEYS: …. No container was run, and Postgres and MySQL were not used.

Environments and settings

GLOBETROTTER_ENV names the environment. Its settings are in designs/components.<env>.json (the studio's Environments view): where each store is, its engine, auth settings, flow durability and the observability exporter.

Unset is refused: the server and migrate stop with one line saying to set it, and anything that is not exactly local is treated as a server. local suits a laptop only (say GLOBETROTTER_ENV=local outright): it restarts on a change, a failed request answers with its exception and line, /docs is served, and the development keys and secrets work. An environment the project does not declare is refused unless each store's address is given (GLOBETROTTER_<STORE>_URL). A file-link secret (GLOBETROTTER_FILE_SECRET) is refused outside local the same way as the session secret.

Secrets are named in the components file as {secret:NAME} and set as environment variables of the same name. globetrotter status lists which each environment needs. A password in a URL is refused. All variables are in the reference.

Health and readiness

Path Answers
GET /health 200 while the process is up. Use as a liveness check.
GET /ready 200 once every store is reached and migrated. 503, saying what is behind, until then. Use as a readiness check.

Neither is in the contract. The contract is /openapi.json.

A boot with a store that cannot be reached is one line, and /ready is 503 saying which store and why, until it can be. A secret missing outside local, or a port taken, is one line and exit 1.

Logs

Logs go to stderr. The app's and your code's are at INFO (LOG_LEVEL), as JSON with the request id when the design's observability is on. One JSON line per request carries request_id and who asked. The trace line beside it carries the trace id, and the worker's trace … on <event> line carries the same one, so an order is followed from the request to its receipt across both logs.

Traces and metrics

Set the design's observability and the environment's exporter to otlp, and point OTEL_EXPORTER_OTLP_ENDPOINT at your collector. redact fields never reach an exporter. Locally the console and backend/.globetrotter/traces.jsonl hold them. See Flows and jobs.

Scaling

Several API processes on one store are fine. WORKERS sets processes per host outside local (default 1; each has its own connection pool to each store). Two relays and two workers are fine: no event is doubled. A row two API processes change in the same moment is a 409 for the one that lost.

A Cache in memory is each process's own; use a Redis store when processes must share it. Files on local disk are not shared between hosts unless GLOBETROTTER_<STORE>_DIR points at a shared volume; a File with backend: s3 is in a bucket every host reaches (set files.<name>.bucket in each environment's components file, and its key and secret, or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, where it runs: the backend refuses to start without them). In Rust the bucket is the cargo feature files-s3, on by default. See Limits.

Stopping

Run the modules under your supervisor directly (.venv/bin/python -m <app>_fastapi), not through uv run: SIGTERM reaches the process through the wrapper, but SIGKILL to the wrapper leaves it running.

  • The API on SIGTERM finishes the requests in flight and exits, in under a second. Take it out of the load balancer first, or requests still sent to it are refused.
  • The worker on SIGTERM finishes the step it is on, then exits (an 8 second step: 6.5 seconds after the signal).
  • Rust does the same on SIGTERM or Ctrl-C, whether it is the API, the worker or the relay: it says Stopping: finishing what is in flight., lets the requests and the step that are running end, and exits 0 (the binary handles the signal itself, so it works as PID 1 in the image). Python's API is uvicorn's own handling, its worker's a handler of the generated worker. A Rust worker whose queue fails ends the process with one line and exit 1.
  • A job longer than the grace: a scheduled job in flight at SIGTERM gets GLOBETROTTER_SCHEDULER_GRACE seconds (30), the one name both targets read (the Python scheduler and the Rust worker, which is the process that runs the jobs there). The Rust worker says Stopping: finishing tickItems (up to 30 s: GLOBETROTTER_SCHEDULER_GRACE); past the grace it marks the run abandoned, says job tickItems did not finish in time: its run is marked abandoned and exits 0. docker stop kills at 10 s, so set the grace under it or raise --time. A run a SIGKILL left running is marked abandoned by the next scheduler (Rust: worker) at its start and each minute, once older than the job's timeout plus 10 s.
  • SIGKILL leaves the step's event held, and it is handed on again when its lease runs out (five minutes). Nothing is lost either way, but that step may run twice.
  • abandoned is the status of a job's run that did not finish: it was still going when the grace ran out, or its process was killed. Nothing is needed from you: the job's next scheduled run starts it again, and get_runs shows each try. A job must be safe to repeat.
  • Exit codes a supervisor sees: 0 after a clean stop; 1 when a part cannot run (a schedule that does not read, a queue that fails, a missing setting); 143 from the Python API under SIGTERM in the image, which is uvicorn's normal stop.

A rollout

A rollout is the new version beside the old: start the new API, move traffic, stop the old one. For a worker, start the new one, then SIGTERM the old.

/ready asks for the revisions the running code was generated with, not for the files on disk. When the new version's migration lands:

  • If it is additive (a column with a default), the old code stays ready on the migrated database and keeps taking orders. A rollback is traffic moved back to it.
  • The new code answers 503 "0007 is waiting" until migrate has run. The migration's NOTE and DESTRUCTIVE lines (sync prints them) say what the old code would not survive.

An upgrade of Globetrotter itself can bring such a migration too, the audit's operation column: migrate, then start. Until then every audited write and the audit reader answer in those words, /health is still 200 and reads still answer (python-audit-operation.txt):

$ curl -s http://localhost:8986/ready
{"status":"not ready","error":"The database is not ready: db is at 0008, 0009 is waiting: in the backend's folder, run GLOBETROTTER_ENV=local uv run python -m fieldops_core.migrate."}

A Rust build says the same, naming the runner that owns the database: cargo run -p <app> -- migrate, or Python's where Python's runner applied it.

One order a second through such a rollout placed 84 orders: 84 rows, 84 receipts, each once.

Backups

Back up the stores, including audit_log, the outbox and alembic_version. See Data and migrations.

Checks to run in CI

backend/ci/github-actions.yml runs the backend's checks. A workflow has to sit in .github/workflows/ at the repository root, which a target does not write into, so copy it:

mkdir -p .github/workflows && cp backend/ci/github-actions.yml .github/workflows/backend.yml

Beside it, in any pipeline:

npx globetrotter sync --check     # an invalid service, a lint error or an out-of-date generated file fails
cd backend && uv sync --frozen && uv run pytest

Next: Auth and security, Data and migrations, Limits.