Getting Started¶
The App Object¶
The central entry point is App. It wires together all components:
App creates these components by default:
| Attribute | Component | Default config |
|---|---|---|
app.shutdown |
ShutdownHandler |
always created |
app.logging |
LoggingHelper |
data/logs/ |
app.settings |
Settings |
data/settings/settings_main.json |
app.diagnosis |
SelfDiagnosisEngine |
always created |
app.status |
StatusEngine |
always created |
app.heartbeat |
HeartbeatEngine |
300s default timeout |
app.version |
VersionInformation |
helper/version.json |
app.fleet |
StatusMonitor |
fleetManagementData/config.json |
Pass None to skip any component:
app = App(
name="my-service",
settings_path=None, # no settings file
fleet_config_path=None, # no fleet reporting
version_file=None, # no version tracking
)
Reading Settings¶
timeout = app.settings.get(["expert", "timeout"], default=300)
# or with dot-notation:
timeout = app.settings.get("expert.timeout", default=300)
Reporting Diagnostics¶
app.diagnosis.notify(code=1001, message="Database unreachable", critical=True)
# Later, when resolved:
app.diagnosis.clear(code=1001)
Heartbeat Watchdog¶
app.heartbeat.register("main-loop", timeout_sec=60)
while not app.shutdown.is_shutdown():
app.heartbeat.register("main-loop", timeout_sec=60) # refresh
do_work()
Fleet Management¶
To report status and diagnostics to the BrinkhausFleetManager, create
fleetManagementData/config.json:
{
"fleetmanagement": {
"customer_name": "my-customer",
"machine": "machine-01",
"broker": "fleet.brinkhaus-gmbh.de",
"heartbeat_interval_sec": 60,
"token": "fmt_..."
}
}
The token is created in the FleetManager UI (Customers → Manage Tokens).
Device identity (optional)¶
Devices provisioned by Brinkhaus carry a fixed serial number. Add these keys to
the same fleetmanagement section to send it, together with the name and
inventory number the customer chose, in every heartbeat:
{
"fleetmanagement": {
"serial_file": "/etc/brinkhaus/serial",
"display_name": "Lathe 1",
"inventory_no": "INV-4711",
"stream": "brinkhaus",
"initial_password_scheme": "hmac-sn-v1",
"initial_password_changed": false
}
}
The serial is read from the first line of serial_file (overridable with the
FLEET_SERIAL_FILE environment variable); a plain serial key is the fallback
when no file is configured. The FleetManager only accepts a serial that was
registered at provisioning or assigned by an administrator, so the name can
change freely while the device stays the same machine. The brand a piece of
software runs under is software-specific and passed to the app instead:
App(name="datastore", branding="uttec"). Every key is optional; missing ones
are simply not sent.
A software that accepts encrypted command parameters passes its public X25519
key the same way, App(name="bos-mainui", command_pubkey="<base64, 32 bytes>").
The identity is read once at start; the few fields a software may change itself
-- initial_password_scheme, initial_password_changed, command_pubkey --
reach the next heartbeat through app.update_identity(...). The serial cannot be
changed that way: it is the device's key and comes from the read-only file.
Release channel. The FleetManager knows the channel (nightly, candidate,
stable) of every version line and returns it with the heartbeat response. A
promotion changes the channel without a new build, so the software asks the fleet
monitor instead of carrying it:
app.fleet.set_build_channel("candidate") # the channel this build was delivered with
channel = app.fleet.channel() # ("stable", "fleet") or ("candidate", "delivery") or None
The source "fleet" is the current channel, named by the FleetManager while the
client is connected; "delivery" means it has not named one (no connection, or it
does not know the line) and the value may be outdated - show it marked as "at
delivery". The Rust client and monitor offer
the same pair, set_build_channel() and channel() with ChannelSource.
With the config in place, App automatically starts the fleet monitor:
Any diagnostics reported via app.diagnosis.notify(...) are automatically
forwarded to the FleetManager every 60 seconds.
See Fleet Management API reference for standalone usage, environment overrides, and endpoint details.
Adding a REST Server¶
Install the rest extra, then:
from brinkhaustools.rest import RestServer
server = RestServer(app=app, port=8080)
server.start()
app.wait()