Worker process
The replica starts the SDK worker. You do not pass a token on the command line.
python -m surfra.workerThe process exits if any of these are empty:
| Variable | Who sets it |
|---|---|
SURFRA_MASTER |
Autoscaler |
SURFRA_REPLICA_TOKEN |
Autoscaler. One token, used by every worker on that replica |
SURFRA_ENTRYPOINT |
Path to the handler file inside the image |
SURFRA_ONCE=1 runs a single successful batch and then exits. Leave it unset in production.
- Import the entrypoint so
@surfra.warmupand@surfra.handlerregister. - Run warmup once.
- Start
concurrent_workersthreads. Each thread callsPOST /v1/workers/registerand gets its own worker id. - Each thread polls
POST /v1/workers/nextfor up tobatch_sizemax leased stages. - The handler runs. Results are completed one stage at a time.
None, a short list, or an exception fails every stage in that batch.
The replica token can register at most num_workers worker ids. The first register in a process raises that cap to concurrent_workers when the handler asks for more.
