Background Workers
Long-lived processes with no HTTP port: queue consumers, chat bots, ETL pipelines and anything that should keep running between requests.
When to use a worker#
- Consuming a queue (RabbitMQ, Redis, Kafka) and processing jobs.
- Telegram, Discord or Slack bots on long polling.
- Streaming or ETL processes that read, transform and write continuously.
- Schedulers written inside the app rather than as separate cron entries.
Worker or cron job?
A worker runs continuously. If the task runs on a schedule and exits, use a cron job instead — you only pay for the time it runs.
Creating a worker#
- 1Create the serviceIn console.muerte.cloud press Create service → Background worker.
- 2Connect the repositoryPick the repo and branch, or a Docker image. Auto-deploy on push works exactly as it does for web services.
- 3Set the start commandFor example
node worker.js,python worker.pyorcelery -A app worker -l info. - 4Add variables and resourcesQueue and database credentials go into environment variables. Workers are usually RAM-bound rather than CPU-bound.
No port, no public URL#
A worker gets no public address and no health check on an HTTP port. It is considered healthy while the process is alive. If your process exits, the platform restarts it — an exit is treated as a failure, not as a normal end of work.
worker.js
js
import { consume } from "./queue.js";
async function main() {
for await (const job of consume("emails")) {
await handle(job);
}
}
main().catch((err) => {
console.error(err);
process.exit(1); // let the platform restart the worker
});Graceful shutdown
On redeploy the container receives SIGTERM and a drain window. Stop taking new jobs, finish the current one, then exit — otherwise a deploy can interrupt work mid-flight.
worker.js
js
let stopping = false;
process.on("SIGTERM", () => { stopping = true; });
while (!stopping) {
const job = await queue.take();
if (job) await handle(job);
}
await queue.close();Logs, state and scaling#
- Everything the process writes to stdout and stderr appears in the service logs — this is the primary way to observe a worker.
- Local files disappear on redeploy unless you attach a persistent disk.
- Running several workers on the same queue works only if the queue guarantees a job goes to one consumer — check idempotency before scaling out.
- Deploy history and rollbacks apply to workers the same way as to web services.
Common pitfalls#
Process exits immediately
A worker must block. A script that finishes is a cron job.
No SIGTERM handling
Deploys then cut off jobs in the middle.
Secrets in the repo
Move queue and DB credentials to variables.
Silent failures
Log errors and enable deploy notifications.
Unbounded memory
Batch reads; a full RAM limit restarts the worker.
Assuming local disk persists
Attach a disk if you keep state on the filesystem.