Run your worker in the background
A worker is a long-running process (npm start runs node src/index.js). For development you can keep it in a terminal; to leave it running, fob-worker procs manages it with pm2.
procs needs macOS or Linux and pm2 installed globally:
npm install -g pm2
Start, stop, restart#
From the worker repo's root:
fob-worker procs start # pm2 process named after the folder, e.g. worker-acme
fob-worker procs logs # tail its output (Ctrl-C to stop tailing)
fob-worker procs restart # after changing code or .env
fob-worker procs stop
From anywhere else, name the worker by its folder name or pm2 name, or give start its path:
fob-worker procs start ~/work/worker-acme
fob-worker procs restart worker-acme
start refuses if the folder isn't a worker repo (its package.json must depend on @fob/lib-worker and have a main entry) or if that worker is already running.
What's running#
fob-worker procs list
PID WORKER MODE PM2 PORT UPTIME STARTED
------------------------------------------------------------------------------------
48211 worker-acme pm2 worker-acme - 02:14:09 Sat Oct 3 12:30:15 2026
procs list finds workers started with pm2 and workers started directly (npm start, node src/index.js), shown as direct. Only pm2 workers can be stopped, restarted or tailed with procs; stop a direct one in its terminal or with kill <pid>.
fob-worker procs monit opens pm2's live CPU and memory monitor.
One worker per location#
The Orchestrator gives each location to one worker at a time. If a second worker starts with the same WORKER_LOCATION, one of them is turned away and exits. Run one worker per location, and stop your local copy before starting the real one elsewhere.
Keeping it running after a reboot#
That's pm2's job: pm2 save and pm2 startup. See the pm2 docs.