Multiple Machines
Run several machines from a single file using defineConfig.
Overview
A single vintage server can host multiple machines simultaneously. Use
defineConfig to declare them in one file:
import { defineConfig } from "@vintage/core"
import TemperatureSensor from "./temperature-sensor"
import PressureSensor from "./pressure-sensor"
export default defineConfig({
"temp-1": TemperatureSensor,
"pressure-1": PressureSensor,
})Run it the same way:
vintage serve setup.tsEach machine gets its own API namespace and its own panel in the web UI.
Per-machine configuration
Pass config inline alongside the class:
export default defineConfig({
"sensor-line-a": {
class: TemperatureSensor,
config: { pollInterval: 1000 },
},
"sensor-line-b": {
class: TemperatureSensor,
config: { pollInterval: 5000 },
},
})Inline config takes priority over any --config file. The --config flag is
not available in multi-machine mode.
Machine IDs
The key you provide in defineConfig becomes the machine ID directly:
defineConfig({
"my-sensor": TemperatureSensor, // id = "my-sensor"
})This ID is used as the API path segment:
| Machine key | State endpoint |
|---|---|
sensor-line-a | GET /api/sensor-line-a/state |
sensor-line-b | GET /api/sensor-line-b/state |
Example: coordinated machines
A common pattern is multiple machines that share a physical installation — each with its own responsibility:
import { defineConfig } from "@vintage/core"
export default defineConfig({
conveyor: { class: ConveyorBelt, config: { speed: 0.5 } },
"arm-left": { class: RobotArm, config: { axis: "left" } },
"arm-right": { class: RobotArm, config: { axis: "right" } },
vision: { class: VisionSystem },
})Each machine runs independently. Coordination between machines (e.g. the vision system triggering an arm action) is handled by your application logic, not by vintage itself.