Lay out a factory repo and push its lines
A factory is a repo of lines and stations. Your code lives under src/stations/; the definitions of your lines and stations live as JSON files under .orchestrator/, and you push them to the Orchestrator with al-orc. Start from the factory template, as in the Quickstart.
factory-acme/
├── src/
│ ├── index.js the factory session: discovers stations, polls, watches bins
│ ├── stations/
│ │ ├── IN0__intake/station.js
│ │ └── IN1__check/station.js one folder per station, its handler in station.js
│ └── shared/ handlers two stations share (optional)
├── .orchestrator/
│ ├── lines/IN.json one file per line
│ └── stations/IN0__intake.json one file per station
├── .env the session's settings and secrets (not committed)
├── .env.example every variable the factory reads, without values
└── temp/ bins and run scratch, created at runtime (not committed)
Line files
A line file is .orchestrator/lines/<CODE>.json. It names the line and says where its stations run:
{
"code": "IN",
"name": "Invoice intake",
"description": "Takes invoices from the inbox, checks them and posts them to the ledger",
"location": "acme-office"
}
| Field | Required | Meaning |
|---|---|---|
code | yes | The line's handle, unique in your organisation: 1 to 50 letters, digits, - or _. Station files name it in line. |
location | yes | Where every station on this line runs. A factory session runs only the lines whose location equals its FACTORY_LOCATION. |
name | no | Display name; defaults to code |
description | no | What the line does, end to end |
A line runs at exactly one location, because its stations hand work to each other through folders on one disk. There is no location on a station. When you change a line's location and push it, runs that start from then on go to the new location; a run already started stays where it was. To run the same work in a second place, see Run a factory session.
Station files
A station file is .orchestrator/stations/<SHORT_CODE>__<name>.json, with IN1__check.json for station IN1 named check. The folder is flat: the line field, not a subfolder, puts a station on its line.
{
"short_code": "IN1",
"line": "IN",
"name": "check",
"description": "Checks each invoice against its purchase order",
"conveyor": { "from": "IN0/output" },
"config": { "approval_limit": 5000 },
"dependencies": ["IN0"],
"is_enabled": true,
"watch_enabled": true
}
Every field is described in the station object reference. What matters for the file:
linemust name a line that exists. Push the line file first. A station with nolinedoesn't push.- No
location. It belongs to the line. al-orc drops alocationit finds in a station file and says so. - Short codes are unique in your organisation. By convention a short code is the line code plus a number, with the line head at
0(IN0,IN1,IN2). A letter after the number marks stations that work side by side at the same stage (IN0a,IN0b). conveyor.fromnames the bins the station takes work from; a line head has none. See Connect stations.configis one JSON object, the config the station's handler gets, checked by itsconfigSchema. The code is found byshort_code: the handler insrc/stations/<SHORT_CODE>__<name>/station.js. See Write a station.- No
steps. A station file withsteps, the format before lib-factory 0.41, is refused by the Orchestrator and by the factory session. The lib-factory README says how to move an old factory over. - See Start stations for
watch_enabledand the schedule fields.
Push and pull
Run al-orc from the factory's root folder. It uses the credentials of its own profile (al-orc config profiles add), not your .env.
al-orc lines push --all # every line file
al-orc stations push --all # every line file first, then every station file
al-orc stations push IN1 # one station, by short code or file name
- A file without an
idis created. al-orc then rewrites it with the record the Orchestrator returns, including the newid, and renames it to<SHORT_CODE>__<name>.json. Commit the rewritten file, so the next push updates the station instead of creating it again. - A file with an
idis updated. If thatiddoesn't exist on the Orchestrator you push to, the push stops.--forcecreates it there with the sameid, for moving a factory to a new organisation or Orchestrator. dependenciescan name short codes; al-orc turns them into ids when it pushes. A pulled file shows ids.tagsare names. A tag that doesn't exist yet is created.[]removes every tag; leaving the field out leaves the tags as they are.
To bring the Orchestrator's copy down, for example in a fresh clone:
al-orc stations pull --all # every line file, then every station file
al-orc lines pull --all # line files only
Your factory session reads the local files too: it uses them to decide which stations to watch. Push every change, so the two copies match.
Next
- Run a factory session: start the process that runs these stations.
- Give stations their credentials: what goes in
.env. - Write a station that processes workpieces: the code under
src/stations/.