alata.
Getting Started

Deployment

Run Alata in production — ASGI server, queue workers, the scheduler, and maintenance mode.

A typical Alata deployment runs an ASGI server, queue workers, and a cron-driven scheduler, each booting the same application configuration in its own process. This page covers how to start each one, how to pin the framework version, and how the framework behaves once the environment is production.

One kernel, every process

Run commands in your application's Python environment. For a process manager, configure that environment's Python executable or its bin directory on PATH.

bootstrap/application.py builds the single Application for your project. Each entry point is a thin view over it:

ProcessEntry pointLoads
HTTP serveruvicorn bootstrap.app:appbootstrap/app.py → app = kernel.fastapi
Console./alata <command>bootstrap/application.py directly
Queue workertaskiq worker bootstrap.broker:brokerbootstrap/broker.py → broker = app.make("queue.broker")

Importing bootstrap/broker.py runs the kernel's synchronous provider registration and boot hooks. Each process gets its own container. Async provider hooks require the application lifespan; importing the broker alone does not run them.

The ASGI server

Point uvicorn at the ASGI entry point:

uvicorn bootstrap.app:app --host 0.0.0.0 --port 8000 --workers 4

main:app is an equivalent target (main.py re-exports the same instance).

You can also use the built-in serve command — reload is disabled automatically when --workers is greater than 1, or explicitly with --no-reload:

./alata serve --host 0.0.0.0 --port 8000 --workers 4 --no-reload

Behind a proxy or load balancer, add your public hostname to the TRUSTED_HOSTS env variable (comma-separated). Trusted-host enforcement switches on automatically when ENVIRONMENT=production; requests with unrecognized Host headers are rejected.

Health probes

Every Alata app exposes framework health routes — wire them into your orchestrator:

  • GET /health — liveness: the process is up.
  • GET /health/db — readiness: runs SELECT 1 on every registered async connection; 200 if all pass, 503 otherwise.
  • GET /health/metrics — connection-pool utilization for dashboards and alerting.

Queue workers

Start a worker with the console command:

./alata queue:work --queue high,default --workers 4

--queue overrides the configured queue. Redis and database workers accept a comma-separated priority list (leftmost is highest); SQS accepts one queue. See queue worker configuration.

Run workers under a process manager, such as systemd or a container orchestrator with restart policies, and restart them after deploying code changes. For a dashboard and worker management, see Horizon. Use ./alata queue:listen with code reload during local development.

The scheduler

Add a single cron entry on one machine (or a dedicated scheduler container) that ticks every minute:

* * * * * cd /path/to/app && /path/to/app/.venv/bin/python alata schedule:run >> /dev/null 2>&1

Use the absolute path to the Python environment where your application's dependencies are installed. schedule:run evaluates the schedule defined in app/console/kernel.py and fires whatever is due. Use on_one_server() on events if you run the cron entry on multiple machines — see scheduling.

Pinning the framework version

Alata installs from PyPI. Declare the supported release range in pyproject.toml:

pyproject.toml
[project]
dependencies = [
    "alata>=0.12.0.1,<0.13",
    "uvicorn>=0.40.0",
]

Commit uv.lock to pin the exact framework version and its dependencies. Install that lockfile in production:

uv sync --locked --no-dev

To upgrade within the supported range, run uv lock --upgrade-package alata, test the application, and commit the updated lockfile. Change the range in pyproject.toml when moving to a new release series.

Production environment settings

Set the environment explicitly:

.env (production)
APP_ENV=production
ENVIRONMENT=production
DEBUG=false

APP_ENV and ENVIRONMENT drive different checks — set both, as covered in configuration. You can also keep one .env and override per environment with a .env.production overlay, or force the environment per command with ./alata <command> --env production.

The exception handler fails closed

The central exception handler resolves the environment once at boot from the settings binding, and treats any APP_ENV starting with prod as production. In production it never leaks internals to clients:

  • ValueError renders as 400 with the generic message "Invalid request." instead of the raw exception text.
  • Database errors render as 500 with "A database error occurred." and details: null.
  • Unhandled exceptions render as a generic 500 — full tracebacks go to your log channels (file, JSON, Sentry), never to the response.

If the environment cannot be determined at all — unbooted container, missing settings — the handler assumes production. Failing closed means a misconfigured deployment hides error details rather than exposing them. If you see generic error messages in local development, check that APP_ENV is set.

Other behavior that shifts with the environment: strict database mode defaults to off in production (EFFECTIVE_DB_STRICT_MODE), trusted-host middleware turns on, and Sentry reporting activates when SENTRY_ENABLED=true and a DSN is set.

Maintenance mode

Take the application offline during risky deploys or data migrations:

./alata down   # enter maintenance mode
./alata up     # back to live

down creates a flag file at storage/framework/down (resolved through base_path(), so it works from any process on that machine). While the flag exists:

  • HTTP — MaintenanceModeMiddleware returns 503 for every request, except the configured bypass paths (middleware.maintenance_mode.bypass_paths, /health by default) so load-balancer probes keep passing.
  • Scheduler — due events are skipped, unless an event opts in with .even_in_maintenance_mode().

Both commands are idempotent — running down twice, or up when the app is already live, just prints a notice. The APP_MAINTENANCE_MODE=true setting is an env-driven alternative that blocks scheduled events without touching the filesystem (it does not affect HTTP).

The flag file is per-filesystem. If you run multiple app servers, run ./alata down on each host (or share storage/ across them) — the HTTP 503 only applies where the flag exists.

A minimal production checklist

  1. APP_ENV=production, ENVIRONMENT=production, DEBUG=false in the environment.
  2. Dependencies pinned in a committed uv.lock and installed with uv sync --locked --no-dev.
  3. ./alata migrate run as a deploy step (check with ./alata migrate:status).
  4. Uvicorn on bootstrap.app:app behind your load balancer, TRUSTED_HOSTS set.
  5. Workers on bootstrap.broker:broker under a supervisor.
  6. Cron entry for ./alata schedule:run on exactly one node, or on_one_server() everywhere.
  7. Readiness probes on /health/db, liveness on /health.

On this page