Server
sqb location
Run a code location that publishes a project to the server, and check its health.
Run a code location: it compiles the project in its own Python environment, publishes it to the server, and publishes again when the project changes:
export SQLBUILD_LOCATION_TOKEN=...sqb location serve --server https://control.example.com --location-id "$LOCATION_ID" --target productionCreate the location and its token with sqb admin create-location orders and
sqb admin issue-location-token on the server’s host. The location reads the token from
SQLBUILD_LOCATION_TOKEN and never opens the control database.
Check a location’s health
Section titled “Check a location’s health”Ask the server how a location and target are doing, for example from a container health check:
sqb location health --server https://control.example.com --location-id "$LOCATION_ID" --target production{"location_id":"01a1d7ff-0b3a-7631-ba35-e44d44d072f2","target":"production","state":"healthy"}state |
Meaning | Exit code |
|---|---|---|
healthy |
An instance checked in within 90 seconds and its last load published | 0 |
degraded |
The warehouse connection check after the last load failed | 0 |
missing_secrets |
A provider secret is unset in the location’s environment, and the target’s allow_missing_secrets doesn’t list the provider, so runs that use it fail |
1 |
falling_back |
The last load failed, so runs use the previous snapshot | 1 |
broken |
No instance has checked in for 90 seconds | 1 |
The command exits 2 when it cannot read the state: the server is unreachable, or the token is
missing, expired or for another location. It needs the location’s token, not a person’s sign-in.
A Compose health check for the location service:
healthcheck: test: [CMD, sqb, location, health, --server, "http://server:8000", --location-id, "${SQLBUILD_LOCATION_ID}", --target, development] interval: 30s start_period: 60sA falling_back location still runs scheduled jobs from its last good snapshot. Restarting it
does not fix the failed load; fix the project and deploy it again.
Loading a project is a full compile, as sqb compile runs it, including the
configured Rules. A Rule finding fails the load like any other compile
error: nothing is published, and the location’s output and its page in the UI show the findings:
Compile failed: 1 rule findingmodels/orders.sql:2:8 [SQBRMODEL102] SELECT * is allowed only inside dependency import CTEsRuns and plan previews on a published snapshot don’t evaluate the Rules again; they passed when it loaded. After a SQLBuild upgrade that adds Rules to a family you select, a location keeps running its last good snapshot until the project passes them.
A missing_secrets location publishes and runs jobs whose nodes have their secrets. Each time it
publishes it reports the providers missing secrets, with their variables and the nodes that use
them, and prints them in its output. Its page in the UI lists them, and the Overview shows the
problem. A run that needs one fails those nodes with D012 before connecting to the warehouse and
skips the nodes that read them. Set the missing variables in its environment or env file and
restart it; sqb debug in the location lists them too. A provider the target allows to miss its
secrets shows as a note on the location’s page instead.
Provide settings and secrets
Section titled “Provide settings and secrets”A location reads provider settings from its environment and from the project’s env file, which it loads once when it starts. For a deployment, point the target at a file outside the project:
[targets.production]env_file = "/etc/opt/sqlbuild/sqlbuild.env"The location stops at start-up with an error naming the file when it doesn’t exist. Variables set in the container or service environment win over the file. After changing the file, restart the location so its compiles and plan previews use the new values. Each worker reads the file when its run starts.