Skip to main content

Module roles

Module roles 

Source
Expand description

The server roles as processes of their own (M2.1): schedr master, schedr webserver and schedr worker, and the pieces schedr standalone runs together in one process.

  • master: the gRPC service workers connect to and the master’s loop, on the database (Postgres, or SQLite on one host); it refuses an outdated schema (schedr db migrate runs first) and picks commands up at once on Postgres (LISTEN/NOTIFY), else by polling.
  • webserver: the REST API on the same database.
  • worker: the agent, connected to [worker] master_url, and its log endpoint (the webserver reads task logs from it), with log retention; no database.

The internal links (worker → master, webserver → worker logs) use mTLS in [tls] mode = "app" (the default: each role needs [tls] ca, cert and key, read again when they change) and plain traffic in mesh mode, where a service mesh encrypts. SIGTERM and Ctrl-C stop a role (a worker drains first). See archive/PROJECT.md, Architecture: Components and roles.

Structs§

ApiTimings
How long the webserver waits and refreshes.
LocalUi
The web UI schedr standalone serves next to its API, over its own deployment.
MasterOutbox
The master’s notifications: [notifications] checked, with its sender’s timings.
Observed
How a part of a role is observed: its metrics (registered by the caller), the health it reports its loops to, and the readiness it sets once started.
WorkerLinks
How a worker reaches the master and serves its logs.

Constants§

LOCAL_DEPLOYMENT
The name of the deployment schedr standalone’s UI shows (in its URLs).
REQUESTS_GRACE
How long open requests get once a stop is asked for, before they are cut: an event stream never ends by itself, and a page reconnects to the next server (B26).
SCHEMA_RETRY
How often a webserver checks again for a schema it can use.

Functions§

agent_settings
The worker agent’s settings, from the configuration; its journal is <data_dir>/journal/<worker ID> and its logs <data_dir>/logs/<worker ID> (other bytes than letters, digits, -, _ and ., and a leading ., as %XX), so workers sharing a data directory never see each other’s (retention, the log endpoint). Without [worker] memory_reserve, the task budgets leave default_reserve of the pod’s limit out.
apply_change_notifications
Turns the database’s change triggers on or off as [database] change_notifications says (decision 38A’), logging a change; done where migrations are, holding the master’s lease.
auth_timings
How the users and the UI’s token are followed, by timings, and how much is remembered.
check_timeouts
Checks that query_timeout and lease_period are shorter than loop_stall_timeout, so one hung query doesn’t look like a stuck loop, and a stuck master doesn’t lead past its restart.
check_ui_port
Checks that [webserver] ui_port_in_mesh is set only in [tls] mode = "mesh".
client_timeouts
How long the UI waits for its webservers (SCHEDR_HIDDEN__CLIENT__*, decision 493).
connect_database
Connects to the database of the master or the webserver, whatever its schema: [database] url is required, SQLite is for one host (it warns).
data_dir
Where task logs (and standalone’s SQLite file) go: [worker] data_dir, else $XDG_DATA_HOME/schedr, else ~/.local/share/schedr.
docs_dir
[ui] docs_dir when it is a directory; None otherwise ("", or not there: no /docs).
lead
The master’s lease for role (master or standalone), being taken while the role’s other parts start when the schema is usable; else, with --migrate, taken now (a standby waits) and the schema migrated by its holder; taken as holder (the master’s ID). None when a shutdown is asked for while waiting. With --migrate, [database] change_notifications is applied by the holder.
listen
Binds a TCP listener.
lock_journal
Takes the worker’s journal lock for as long as the returned file is open: one agent per worker ID and data directory.
log_endpoint
Where the webserver reaches this worker’s log endpoint listening on port: [worker] log_address (else the host name), over https with TLS.
log_mode
[worker] log_mode as a mode (the loader checked it).
log_retention
The worker’s log retention, from the configuration.
master
schedr master: the gRPC service and the loop, until Ctrl-C or SIGTERM.
master_host
Checks [worker] master_url and returns its host: an https:// URL with a host in app mode (the master’s certificate must name the host), an http:// one in mesh mode.
master_outbox
[notifications] with the values its webhooks’ headers read from env.
master_settings
The master’s timing, from the configuration.
memory_text
What the watchdog does, for the worker’s startup line.
memory_watch
How the memory watchdog watches tasks: [worker] memory_budget, else (limit − the reserve) ÷ slots, the reserve [worker] memory_reserve or default_reserve; without a budget or a limit it only measures.
migrate_holding
Migrates db (see unlimited) while holding lead, renewing it as the migration runs.
migrate_leased
schedr db migrate: migrates the database at url holding the master’s lease, so no master runs on the schema meanwhile and no other migration runs at once (sqlx’s own lock is a session lock, which a pooler in transaction mode doesn’t keep). Refused while a master holds it, unless wait.
no_auth_warning
The warning for the REST API listening on address beyond loopback: it has no authentication of its own until the auth modes (M3.5). alternative says how to keep it local.
no_auth_warning_for
As no_auth_warning, for what (the REST API, the web UI).
once_reached
attempt’s output once the database at url answers: while it fails because the database can’t be reached for now (schedr_db::DbError::is_transient: down, starting, busy, a time limit), tried again every retry. A role starting before its database waits for it instead of exiting (the user, 2026-11-15, after B247); a wrong host or port fails the same way, so the warning names where it looks (the host and port, or the file: never the user or password) and why (codes only), at once and again every minute while it waits. None once a shutdown is asked for, before or during a try.
role_auth
Who the user is for the role what (webserver, ui) listening on address, by section; a UI trusted by the token in ui_token_file. The safety rules (see archive/PROJECT.md, Authentication): proxy_header beyond a loopback address only with allow_remote (anything reaching it around the proxy could name any user), basic only with behind_tls_proxy (passwords would cross the network in the clear).
role_tls
The role’s TLS material by [tls]: none in mesh mode; in app mode the files, which must be configured and usable.
run_worker
Runs a worker agent connected to the master until it has drained after a stop request (stop counts them; see schedr_agent::drain), with its log endpoint and log retention beside it until then.
secure_logs
Readies the worker’s logs for mode ([worker] log_mode, B182), as it starts: the logs it creates get it, and its log directory and the logs already in it are given it.
serve_api
Serves the REST API on listener until stop, reading task logs from workers (over mTLS with tls), showing this webserver as node (GET /api/v1/deployment); with ui, the web UI too, at /, calling this API in process.
serve_master
Serves the master: its gRPC service on listener (over mTLS with tls) and its loop, until stop, once leadership has taken the lease (a standby waits there).
served
server (shutting down gracefully on stop) until it ends; once stop asks, its open requests get grace and are then cut.
start_ops
Binds the ops port ([ops] bind : port) and serves ops there until stop, logging the address as schedr <role>: ops on http://<address>.
stop_on_signal
A count of stop requests (Ctrl-C or SIGTERM): the first stops a role (a worker drains), a second makes a draining worker interrupt its tasks at once. The SIGTERM handler is registered before this returns, so a SIGTERM right after start still stops the role gracefully.
take_lease
Waits for the master’s lease (see Leadership::take) as holder (a new incarnation of the master of role: crate::node::new_master_id), logging once that it waits as a standby.
ui
Runs schedr ui: the web UI over the webservers of [ui] deployments, until a signal.
ui_deployments
The deployments [ui] deployments names, each with a client of its webserver’s API.
ui_timings
How a UI’s live pages are paced, by timings, and how far a browser may fall behind.
unlimited
The database at url without a query limit, for a migration (a long one must finish); limited itself in memory, where another connection would be another database.
until
Completes once stop turns true: how every part of a role learns to stop.
until_stopped
work’s output, or None once a shutdown is asked for.
wait_for_schema
Waits until db’s schema is usable by this binary, checking every retry and saying what it waits for whenever that changes (the database unreachable, then a schema to migrate, …; the master, or schedr db migrate, migrates it), so a webserver started before the migration serves once it is done instead of failing.
webserver
schedr webserver: the REST API, until Ctrl-C or SIGTERM.
worker
schedr worker: the agent connected to [worker] master_url, until Ctrl-C or SIGTERM.
worker_timeouts
How long what a worker starts may take, and how it is paced.

Type Aliases§

LeaseFuture
The master’s lease, being taken (see take_lease).