Open Enterprise
Browse topics
DocumentationDeployment

Run the runtime

This guide covers the runtime commands, startup and readiness, shutdown, the database pool, metrics, request correlation, and background jobs. Upgrade the runtime describes migrations during an upgrade.

Commands

Each command takes the configuration file as its second argument. The default is deployments/runtime.yaml.

Command Purpose
serve Serves the API. This is the default command.
migrate Applies pending migrations, then exits.
reencrypt Seals stored secrets again with the current master keys, then exits.
bootstrap Creates an organization and its first owner invitation.
enroll Issues a local account enrollment link, or the first-owner setup link with --initial-owner.
account Shows, disables, enables, or recovers a user's account, resets two-step verification, or turns local passwords off and on for one user.
identity-migration Plans, runs, and reports bulk links from users to an organization's SSO identities.
operator-entry Prints a one-use link for the short-lived deployment console.
check-config Validates the configuration without database or network access.
openapi Prints the OpenAPI document. It takes no configuration file.
keygen Prints a new service key and its SHA-256 digest. It takes no configuration file. The key also works as a local or master key.

enroll, account, and identity-migration print JSON and act as the operator cli. Their arguments are in the local accounts guide.

Startup and readiness

serve opens its listener before it connects to PostgreSQL. Startup runs the following steps in order. database, migrations, directories, oidc, ssf, and authzen.

Deployment OIDC connections load their settings at startup and discover upstream metadata and signing keys on first use. Concurrent logins for one issuer share the attempt. A failed discovery can retry after five seconds. Other connections and local recovery remain available when storage is ready. Customer-managed OIDC configuration tests still contact the issuer and require public HTTPS endpoints in production. Operators can configure trusted internal issuers in the deployment.

While startup runs, the runtime answers like this:

  • /healthz returns 200.
  • /readyz returns 503 with {"status":"starting","step":"<step>"}.
  • Every other path returns 503 with the error code unavailable and Retry-After: 5.

When PostgreSQL or a required startup dependency is unavailable, startup waits and tries again. The delay starts at one second and doubles up to 30 seconds. Other errors stop the process with a nonzero exit code. Examples are a missing environment variable, an invalid credential digest, and a migration history that does not match the build.

After startup, /readyz returns 200 while the database answers, and 503 when it does not. Use /healthz for liveness and /readyz for readiness. A liveness probe on /readyz would restart replicas during a database outage.

Migrations at startup

By default, serve applies pending migrations at startup. To apply them with a separate database role, set this in the configuration:

YAML
storage:
  migrate_on_startup: false

Then run enterprise-runtime migrate with the migration role before you start the target version. With the setting off, a replica only checks that the schema is current. If migrations are pending, the replica stays at the migrations step, returns 503 from /readyz, and logs the pending versions. It becomes ready after the migrations run.

A replica of an older version can run against a schema that a newer version migrated, as long as migrate_on_startup is false. With the setting on, the older replica finds migrations it does not know and exits.

Shutdown

On SIGTERM or SIGINT, the runtime stops accepting connections and stops starting background jobs. It then waits for requests, webhook deliveries, and job runs in flight. server.shutdown_grace_seconds bounds that wait; the default is 20 seconds and the limit is 600. Work still running at the end of the grace period is abandoned. Webhook deliveries that do not finish are retried after their lease expires.

Set the orchestrator's termination grace period above shutdown_grace_seconds. The Helm chart sets terminationGracePeriodSeconds: 30 against a default of 20.

Database pool

storage.max_connections sets the size of the PostgreSQL pool on each replica. The default is 16 and the limit is 1000. Size it so that the replica count times the pool size, plus the migration and administration connections, stays under the server's max_connections. A request that waits more than five seconds for a connection fails with 503. Every statement has a 10 second timeout.

Metrics

Set server.metrics_port to serve Prometheus metrics at /metrics on a separate listener. The port must differ from server.port. Do not expose it on the public network.

Metric Type Labels
oe_ready gauge
oe_http_request_duration_seconds histogram method, route, status
oe_job_runs_total counter job, outcome
oe_webhook_deliveries_total counter outcome
oe_db_pool_connections gauge state
oe_db_pool_max_connections gauge
oe_signal_inbox gauge state
oe_local_logins_total counter outcome
oe_auth_throttled_total counter kind
oe_email_deliveries_total counter outcome, template

route is the route template, such as /v1/organizations/{id}, so the label set stays bounded. Requests that match no route share route="unmatched", and nonstandard HTTP methods share method="OTHER". oe_signal_inbox{state="failed"} counts security signals that were set aside after repeated failures. Alert when it rises; see security signals. Alert when oe_email_deliveries_total{outcome="failed"} rises, and read GET /v1/operator/email-deliveries for the last SMTP error. The pool and inbox metrics appear after startup finishes.

Request IDs and tracing

Every response carries an x-request-id header. The runtime keeps an inbound x-request-id of 1 to 128 letters, digits, -, _, ., or :. Otherwise it generates one. The request log line and the request span include the ID and the route template. SCIM directory activity records the same ID, and the SDK reports it as requestId on errors.

Set OTEL_EXPORTER_OTLP_ENDPOINT to export traces over OTLP/HTTP. A request with a W3C traceparent header joins the caller's trace.

Background jobs

Every replica runs these jobs:

  • Every second: administration activations, permission synchronization, and security signal processing.
  • Continuously, when the events section is configured: event publication, retention, and webhook delivery.
  • With local accounts and SMTP: account email delivery, polling every two seconds when idle.
  • Every hour: expired session and flow cleanup, local account cleanup (expired challenges, login transactions, account-page sessions, throttle counters, and finished messages), event retention when events are off, and audit retention.

Cleanup and retention delete in batches of 2000 rows. They stop after two minutes and continue on the next run. A lease in the maintenance_leases table lets one replica at a time run each cleanup job. A lease expires, so a replica that stops while it holds one does not block the job.

Each replica runs up to 32 webhook deliveries at a time. The per-endpoint delivery interval and ordering still apply.

Rotate master keys

The events, administration, and local_authentication sections each have a secret_key_env and an optional previous_secret_key_envs list. The runtime seals new values with the current key and opens stored values with any configured key.

  1. Add the new key as a previous key on every replica, and roll out.
  2. Make the new key current and the old key previous, and roll out.
  3. Run enterprise-runtime reencrypt with the same configuration.
  4. Remove the old key from previous_secret_key_envs, and roll out.

reencrypt covers customer OIDC client secrets, webhook signing keys, TOTP seeds, and queued account messages. It prints how many values it sealed again, how many were already current, how many changed during the run, and how many no configured key opens. It exits with an error when a value changed during the run or no key opens one. Run it again after a change; investigate unreadable values before you remove a key. Removing an events key also invalidates the feed cursors it signed.

Invalidate an older restored snapshot

Stop replicas and close ingress before enterprise-runtime invalidate-restored-state config.yaml --traffic-stopped. This offline operation revokes restored credentials, disables accounts pending review and preserves canonical identity and policy. Use the database owner's credentials and follow the complete restore procedure.

Search documentation