Operating an installation
What an operator has to do once the three core containers, and optional managed Keycloak, are running.
Derived from services/karyo-app/src/main/resources/application.yaml,
scripts/.env.prod.example, infrastructure/docker/nginx/nginx.conf,
infrastructure/docker/docker-compose.prod.yml and infrastructure/docker/docker-compose.maintenance.yml.
For released images, use scripts/deploy-server.sh --image-only with explicit image references.
The host needs Python and a container runtime with Compose, not a JDK or Node. The existing
Linux/journald platform requirement still applies. Keep the same digest references for a
configuration-only restart. See deploying
for the two modes and their exact prerequisites.
Everything runs in one process
There is one application container and one instance of it. Every background job is a Quarkus
scheduler inside it, and the intervals are configuration
(services/karyo-app/src/main/resources/application.yaml, karyo). In a build of this repository
these are the scheduled jobs:
| Job | Property | Default interval | Default state |
|---|---|---|---|
| Managed-Keycloak login and logout audit poller | karyo.auth-audit.poll-interval |
60s | on in managed mode (KARYO_AUTH_AUDIT); disabled in external mode |
| Webhook fan-out and delivery | karyo.webhooks.poll-interval |
5s | on |
| Replenishment auto-scan | karyo.replenishment.scan-interval |
10m | off (KARYO_REPLENISHMENT_AUTO_SCAN) |
| DELETABLE stock reaper | karyo.inventory.purge.interval |
1h | off (KARYO_INVENTORY_PURGE) |
| System setup account: create once, stop at expiry, apply a reopen | karyo.setup.interval |
1m | on; acts only on a fresh managed installation with a setup password, or on a System that exists |
They are KeycloakEventPoller, WebhookFanoutScheduler and
WebhookDeliveryScheduler, ReplenishmentScheduler, StockPurgeScheduler and
SetupPrincipalScheduler.kt,
each with ConcurrentExecution.SKIP, so a slow tick is never overlapped by the next one.
The managed-Keycloak poller writes to the Company sign-in log, including platform and unresolved identities.
GET /api/v1/sign-in-log requires users.manage at Company node 1; site grants cannot read it.
ADR 0049 covers preservation of the old records and the unchanged poller limitations.
"Default state" is the schedule, not the feature: automatic replenishment scanning, for example, also has to be wanted by a goods owner (see replenishment).
Five more intervals in the same file belong to engine modules - monitor evaluation
(karyo.monitors.interval, 5m), alert delivery (karyo.monitors.delivery-interval, 30s), the
cross-dock expiry sweep (karyo.crossdock.sweep-interval, 5m), wave auto-release
(karyo.wave.auto-interval, 5m) and order-streaming release (karyo.streaming.interval, 5s)
(application.yaml, karyo.monitors, karyo.replenishment, karyo.crossdock, karyo.wave, karyo.streaming). Their schedulers live in the engines and run on every
installation; each engine's own switches decide whether a tick finds work (see
engine capabilities).
Monitor evaluation also pauses while the installation's profile does not enable Monitors
(ADR 0052).
The delivery batch sizes, attempt limits, time-outs and back-off of the webhook relay
(KARYO_WEBHOOKS_*) and of alert delivery (KARYO_MONITORS_DELIVERY_*) are environment settings
too. Strategies and runtime configuration, section 5
names each one, and scripts/.env.prod.example lists them.
Two of the jobs are irreversible or externally visible and are off by default for that reason.
The stock reaper "hard-deletes DELETABLE stock units past their retention window, then the unit
loads they leave empty. Off by default on purpose; only enable once you mean it"
(scripts/.env.prod.example, KARYO_INVENTORY_PURGE, KARYO_INVENTORY_PURGE_INTERVAL, application.yaml, karyo.inventory.purge). Its retention window is a
runtime-configuration property, karyo.inventory.purge.retention-days, rather than an
environment variable, because retention is a data policy, not an operations preference
(application.yaml, karyo.inventory.purge.enabled, karyo.inventory.purge.interval) - the reason two knobs that look alike live in different places (see
the runtime configuration store). Its
batch-size caps both candidate queries per call "so one tick is bounded and progress is
monotonic even under a partial failure" (application.yaml, karyo.inventory.purge.batch-size).
Three integrations default to inert. Two use a non-empty placeholder rather than an empty value,
because SmallRye Config treats an empty resolved value as missing and fails boot:
karyo.print.url is none, and the mailer is mock: true so that
"no real mail leaves the box until SMTP is explicitly configured" (application.yaml, quarkus.mailer.mock, quarkus.mailer.username, quarkus.mailer.password).
The third, Loci, may be empty: karyo.slotting.loci.base-url and the four token keys are
injected as Optional, so an unset base URL means "there is no slotting advice, and the Slotting
page says it requires Loci" and an unset token URL means Karyo sends no credential, instead of a
boot failure (application.yaml, karyo.slotting.loci, SlottingConfig).
karyo.demo.enabled is off (application.yaml, karyo.demo.enabled), and the environment template says it
"MUST stay unset/off in real customer deployments" (scripts/.env.prod.example, KARYO_DEMO).
What an operator can see
Health. External uptime monitors use GET /q/health/live on the public origin. It returns
{"status":"UP","checks":[]} without database or identity-provider detail. It proves that the
application answers, not that its dependencies are ready. nginx returns 404 for every other
/q/ path, including /q/health, /q/health/ready and /q/health/started.
Container health checks still use http://localhost:8080/q/health/ready inside the application
container (docker-compose.prod.yml, services.karyo-app.healthcheck). A readiness monitor must
join the private container network and read that port; do not publish it to restore an old probe.
Readiness returns 503 when a dependency is down. Keep dependency checks out of liveness, so a
transient dependency failure does not trigger application restart loops.
Admin > Health reads GET /api/v1/admin/health with the signed-in session. It requires
settings.manage at the Company, like the page itself. Refusals use the standard 401/403 problem contract.
An authorized response includes the readiness status, individual checks and their data, with
Cache-Control: no-store. It returns HTTP 200 for both UP and DOWN reports; use the body status
for diagnosis, not this API's HTTP status as a readiness probe.
Metrics. quarkus-micrometer-registry-prometheus is on the classpath
(services/karyo-app/build.gradle.kts, libs.quarkus.micrometer.registry.prometheus) and its endpoint is not routed, so there is no scrape
path from outside the container network, and no collector or dashboard ships
(ADR 0025). A metrics
endpoint existing in the image does not prove that anything monitors the installation.
Tracing. quarkus-opentelemetry is in the image (services/karyo-app/build.gradle.kts, libs.quarkus.opentelemetry) and
the %prod profile sets quarkus.otel.sdk.disabled: true (application.yaml, %prod.quarkus.otel.sdk.disabled). Nothing
exports spans in production.
Logs. In %prod the application logs JSON to the console at INFO
(application.yaml, %prod.quarkus.log.console.json.enabled, %prod.quarkus.log.level), so the container log is the record
(ADR 0026). nginx writes an access log
in a custom format that redacts credential-bearing query strings, and the reasoning is precise
enough to be worth carrying: both front ends run the authorisation-code flow with
responseMode: 'query', so every login arrives as GET /?code=...&state=..., and nginx's built-in
combined format would write that authorisation code into the log, where log shipping, a support
bundle or a screenshot of a tail would re-expose it (nginx.conf, map $args $logged_request, map $http_referer $logged_referer).
Only a query that carries a credential is blanked; every other request logs its raw request line,
so a malformed request nginx rejects with 400 still shows what the client actually sent
(nginx.conf, map $args $logged_request, map $http_referer $logged_referer, log_format karyo). id_token_hint is matched with its suffix because keycloak-js puts the full
signed ID token there on RP-initiated logout, and a bare id_token= pattern would never fire.
state and session_state are deliberately not triggers and must not be added: state is a
live application query filter on delivery orders, advance shipping notices, goods receipts,
transport orders, waves and cross-dock orders, and matching it would blank the query of ordinary
requests and hide exactly what an operator diagnosing one needs.
The production Compose file sends all four services to the host's journald logging driver,
with a stable <Compose project>/<service> tag. Every deploy still runs compose down
(deploy-server.sh, Stage 6: Start infrastructure (compose down)), but removing a container
does not remove its journal entries. They remain available through journalctl, including
entries from earlier container IDs. Nothing ships them off the host.
Retaining container logs
Production requires a Linux host with systemd-journald available to the container runtime.
Configure persistent, bounded retention before the first deployment or the next upgrade.
The checked-in policy is infrastructure/logging/karyo-journald.conf. It uses persistent
storage under /var/log/journal, rotates journal files at 64 MiB or one day, caps persistent
journal use at 1 GiB, leaves 1 GiB free, and removes entries older than 14 days. Size or
free-space pressure can remove entries earlier: 14 days is a ceiling, not a guaranteed history.
The temporary journal also has explicit size limits while persistent storage is unavailable.
This policy affects the host's journal, not just Karyo. The host administrator must agree its limits with other workloads. Do not apply it to a shared CI runner as part of a test. On an approved installation host:
- Review
infrastructure/logging/karyo-journald.confagainst the site's retention requirements. - Install the policy:
sudo install -Dm644 infrastructure/logging/karyo-journald.conf /etc/systemd/journald.conf.d/karyo.conf - Apply the policy during an approved maintenance window:
sudo systemctl restart systemd-journald - Flush the temporary journal to persistent storage:
sudo journalctl --flush - Check the journal's disk usage:
sudo journalctl --disk-usage
To read application logs after a redeploy, including removed containers, use the stable tag:
sudo journalctl CONTAINER_TAG=karyo-prod/karyo-app --since '2 hours ago' -o cat
sudo journalctl CONTAINER_TAG=karyo-prod/nginx --since '2 hours ago' -o cat
Replace karyo-prod with the deployment's COMPOSE_PROJECT_NAME when it differs. PostgreSQL
and managed Keycloak use the same tags ending in /postgresql and /keycloak. Add
CONTAINER_ID_FULL=<old-id> to isolate one container, or -o json to retain journal metadata
when exporting incident evidence. compose logs addresses current containers, so it is not the
way to retrieve entries after compose down.
Verify retention on a planned redeploy by noting a startup entry, redeploying, and finding that
same entry through journalctl afterwards. The host policy controls rotation; Compose has no
per-container journald rotation option. Existing host policies, journal rate limits and disk
pressure also apply. Monitor disk usage and export incident evidence before its retention
window ends. These local operational logs are not a durable audit archive or a backup.
Rotating credentials
- The PostgreSQL role password. PostgreSQL applies
POSTGRES_PASSWORDonly while initialising a fresh data directory, so changing the application/PostgreSQL values, plus the managed Keycloak value when selected, does not touch the persisted role. The deploy script makes that loud rather than silent, and the rotation procedure is in deploying. Its care is worth noting: both passwords are read at hidden prompts, the new one is validated against the deploy's own credential policy before the role changes, and theALTER ROLEis issued throughpsql's\getenv, so neither password appears in process arguments, the SQL program or shell history. In managed mode, Keycloak and the application restart together. OIDC_SECRETandKEYCLOAK_ADMIN_CLIENT_SECRETare rotated through the realm procedure.- The licence is retired:
KARYO_LICENSE_KEYandKARYO_LICENSEare ignored and need no rotation, and can be removed (licence settings (retired)).
Provisioning the first administrator
A valid provider token never creates or elevates a principal at first login. On a fresh managed
installation, Karyo creates System, the setup account: the implementer signs in as system
with the one-time password in scripts/.karyo-setup-password, creates the first Administrator and
Manager, and confirms that setup is complete, which disables System. System also stops by itself 14
days after installation, and only a server-side KARYO_SETUP_REOPEN marker with a new
KARYO_SETUP_PASSWORD reopens it
(ADR 0053). With an external provider,
or on an installation that already has principals, the first provider account is enrolled as a Karyo
principal by the reviewed identity manifest. The steps are in
deploying and the
identity principal upgrade.
The managed-Keycloak maintenance window
This section applies only to the managed-identity profile. An ordinary deployment has no path to
Keycloak's administration interface at all: the production
Compose file publishes no Keycloak port, and nginx proxies /auth/ only for the realm endpoints
the front ends need. docker-compose.maintenance.yml is the only way to open one; it binds to
127.0.0.1, and taking it down again is a mandatory numbered step of both the realm-change and
rollback procedures rather than a clean-up afterthought (docker-compose.maintenance.yml, services.keycloak.ports).
The port itself is validated like everything else: KARYO_KEYCLOAK_MAINTENANCE_PORT must be an
integer from 1 through 65535 and may be assigned at most once (deploy-server.sh, validate_env (KARYO_KEYCLOAK_MAINTENANCE_PORT check)).
Verifying an installation
Record actual against expected, not just the deploy script's exit status. Every item here names something an operator would otherwise be tempted to infer:
- The selected Compose project, the running image IDs and architecture, the application and nginx images as a matched pair, readiness, and the first boot logs. The deploy's final 200/401/403 probes prove routing, not authorised functionality.
- Desktop and floor sign-in with the intended identities, through the exact public origin and its silent single sign-on callbacks rather than a familiar hostname; role and owner refusals; the bootstrap and any temporary maintenance access retired; System disabled once setup is complete, its password file deleted, and the profile on Admin > Capabilities the one the site chose.
GET /api/v1/licensereportscommunityand every capability key to a signed-in user; any extension is discovered and behaves; the safety invariants are unchanged. Never paste a bearer token into a record.- The agreed acceptance run: receipt finish and putaway, the amount, reserved and available ledger, pick, pack, manifest and dispatch, held, short and wrong-owner cases, and every required interface. On a live installation use approved acceptance records only - never a destructive end-to-end suite, the demo reset or the stock reaper.
- Front-end freshness on desktop and floor, no stale offline queue on a floor device mistaken for a server commit, nginx reaching its upstreams, the backup schedule, and observed logging. An external printer, carrier or webhook succeeding needs an actual acknowledgement, not a downloaded document or an outbox row.
Say plainly whether a fix is proposed, merged, released or installed; none of them implies the next.
Related
- Deploying - the runbook for everything above that needs a command
- Upgrade, backup and recovery - backing up Karyo and, in managed mode, Keycloak
- Identity principal upgrade - the manifest cutover, stop conditions and fix-forward boundary
- Troubleshooting - failures an installation produces after it is running
- Runtime and configuration - how configuration resolves inside the application