Self-hosted distributed job scheduler: cron, delayed & queue jobs with retries (API + worker)
365
Self-hosted, distributed job scheduler. Run cron and one-time schedules, immediate and delayed background jobs, and queues with retries. Every attempt is tracked durably in PostgreSQL, and crashed workers are recovered.
This image contains the API server, scheduler, worker and database migrations. The
optional web dashboard is cronouss/cronous-dashboard.
@cronous/cronous| Tag | Meaning |
|---|---|
latest | Newest release |
0.1, 0.1.1, … | A minor line, or an exact version (recommended for production) |
Images are built for linux/amd64 and linux/arm64.
runAt, time zones and DST, misfire policies, overlap controlSave this as compose.yaml. It runs Chronos with PostgreSQL, Redis and the web dashboard:
services:
postgres:
image: postgres:17-alpine
restart: unless-stopped
environment:
POSTGRES_USER: chronos
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
POSTGRES_DB: chronos
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U chronos -d chronos"]
interval: 5s
timeout: 3s
retries: 20
redis:
image: redis:7.4-alpine
restart: unless-stopped
command: ["sh", "-c", "exec redis-server --appendonly yes --maxmemory-policy noeviction --requirepass \"$$REDIS_PASSWORD\""]
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:?set REDIS_PASSWORD in .env}
volumes:
- redis-data:/data
healthcheck:
test: ["CMD-SHELL", "redis-cli -a \"$$REDIS_PASSWORD\" --no-auth-warning ping | grep -q PONG"]
interval: 5s
timeout: 3s
retries: 20
chronos:
image: cronouss/cronous:0.1.1
restart: unless-stopped
environment:
DATABASE_URL: postgresql://chronos:${POSTGRES_PASSWORD}@postgres:5432/chronos
REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0
CHRONOS_MIGRATE_ON_START: "true"
ports:
- "127.0.0.1:8080:8080"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
dashboard:
image: cronouss/cronous-dashboard:0.1.1
restart: unless-stopped
environment:
CHRONOS_API_URL: http://chronos:8080
ports:
- "127.0.0.1:3000:3000"
depends_on:
chronos:
condition: service_healthy
volumes:
postgres-data:
redis-data:
Create a .env file next to it with two passwords (hex is URL-safe), then start the stack:
echo "POSTGRES_PASSWORD=$(openssl rand -hex 32)" > .env
echo "REDIS_PASSWORD=$(openssl rand -hex 32)" >> .env
docker compose up -d
docker compose logs chronos | grep -A2 "bootstrap token"
/dashboard/)If your compose.yaml already has PostgreSQL and Redis, add only this service. Create a
chronos database first, and make sure Redis uses maxmemory-policy noeviction:
chronos:
image: cronouss/cronous:0.1.1
restart: unless-stopped
environment:
DATABASE_URL: postgresql://chronos:PASSWORD@postgres:5432/chronos
REDIS_URL: redis://:PASSWORD@redis:6379/3
CHRONOS_MIGRATE_ON_START: "true"
ports:
- "127.0.0.1:8080:8080"
depends_on:
- postgres
- redis
Your other services reach it at http://chronos:8080.
The full compose file from the releases also includes optional workers and a standalone
scheduler:
curl -fsSLO https://github.com/mdsharifulislam-r/cronous/releases/latest/download/compose.yaml
docker run -d --name chronos --restart unless-stopped \
-p 127.0.0.1:8080:8080 \
-e DATABASE_URL=postgresql://chronos:PASSWORD@db-host:5432/chronos \
-e REDIS_URL=redis://:PASSWORD@redis-host:6379/0 \
-e CHRONOS_MIGRATE_ON_START=true \
cronouss/cronous:latest
Requirements: PostgreSQL 17 and Redis 7.4 (verified). Redis must use
maxmemory-policy noeviction. Chronos prefixes all its Redis keys, so it can share a Redis
instance with your applications.
On first start, the server prints a one-time bootstrap token in its log (docker logs chronos).
Use it once to create the admin user, organization and first project:
curl -sS -X POST http://127.0.0.1:8080/v1/bootstrap \
-H "Authorization: Bearer $BOOTSTRAP_TOKEN" -H 'Content-Type: application/json' \
-d '{"admin":{"email":"[email protected]","name":"You","password":"a-long-passphrase"},
"organization":{"name":"Acme","slug":"acme"},
"project":{"name":"Storefront","slug":"storefront","timezone":"UTC"}}'
The response contains a project API key (chr_p_…) and an agent token (chr_a_…).
They are shown only once, so store them safely. You can also open the built-in UI at
http://127.0.0.1:8080/dashboard/.
The same image runs every role:
| Command | Role |
|---|---|
(default) node dist/main.js | API server, with the scheduler and webhook worker embedded |
node bin/scheduler/main.js | Standalone scheduler (set CHRONOS_EMBEDDED_SCHEDULER=false on the server) |
node bin/worker/main.js | Central worker running your mounted handlers (CHRONOS_WORKER_HANDLERS=/handlers/handlers.js) |
/app/bin/migrate | Apply database migrations and exit |
| Variable | Default | Description |
|---|---|---|
DATABASE_URL | required | PostgreSQL connection URL |
REDIS_URL | required | Redis connection URL (rediss:// for TLS) |
CHRONOS_MIGRATE_ON_START | false | Apply pending migrations before starting (safe with several replicas) |
CHRONOS_BOOTSTRAP_TOKEN | generated | Set your own one-time setup token instead of reading it from the log |
CHRONOS_NAMESPACE | chronos | Prefix for Redis keys and queues |
PORT | 8080 | Listen port |
LOG_LEVEL | info | fatal … trace |
CHRONOS_TRUST_PROXY | false | Enable only behind your own reverse proxy |
CHRONOS_CORS_ORIGINS | empty | Browser origins allowed to call the API directly |
CHRONOS_EMBEDDED_SCHEDULER / CHRONOS_EMBEDDED_WORKER | true | Run scheduling and webhook delivery inside the server |
CHRONOS_WORKER_CONCURRENCY | 10 | Parallel executions per worker |
CHRONOS_EXECUTION_RETENTION_DAYS | 30 | How long finished executions are kept |
All variables are listed in the environment reference.
GET /health/live: the process is upGET /health/ready: PostgreSQL and Redis are reachable (503 otherwise)The image has a built-in HEALTHCHECK, runs as the unprivileged node user, uses tini as
init, and stops gracefully on SIGTERM.
npm install @cronous/cronous
import { Chronos } from '@cronous/cronous';
const chronos = new Chronos({ server: 'https://chronos.example.com', project: 'storefront' }); // CHRONOS_AGENT_TOKEN
chronos.task('daily-report', { schedule: '0 2 * * *' }, async (ctx) => { /* … */ });
await chronos.start();
await chronos.queue('send-email', { to: '[email protected]' }, { delay: 60_000 });
127.0.0.1 or a private network. Put a TLS reverse proxy in front before you expose it.Content type
Image
Digest
sha256:373871744…
Size
171.5 MB
Last updated
about 4 hours ago
docker pull cronouss/cronous