Skip to content

Commit be7e14b

Browse files
Sync docs from wheels@cfe1bc3
1 parent 0cbdc98 commit be7e14b

File tree

8 files changed

+567
-5
lines changed

8 files changed

+567
-5
lines changed

docs/3.1.0/guides/SUMMARY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@
9999
* [wheels plugin init](command-line-tools/commands/plugins/plugins-init.md)
100100
* Asset Management
101101
* [asset management commands](command-line-tools/commands/assets-cache-management.md)
102+
* Job Commands
103+
* [wheels jobs work](command-line-tools/commands/jobs/jobs-work.md)
104+
* [wheels jobs status](command-line-tools/commands/jobs/jobs-status.md)
105+
* [wheels jobs retry](command-line-tools/commands/jobs/jobs-retry.md)
106+
* [wheels jobs purge](command-line-tools/commands/jobs/jobs-purge.md)
107+
* [wheels jobs monitor](command-line-tools/commands/jobs/jobs-monitor.md)
102108
* CLI Development Guides
103109
* [Configuration Management](command-line-tools/configuration.md)
104110
* [Creating Commands](command-line-tools/cli-guides/creating-commands.md)
@@ -120,6 +126,7 @@
120126
* [Contributing to Wheels Windows Installer](working-with-wheels/contributing-to-wheels-windows-installer.md)
121127
* [Contributing to Wheels macOS Installer](working-with-wheels/contributing-to-wheels-macos-installer.md)
122128
* [Background Jobs](working-with-wheels/background-jobs.md)
129+
* [Dependency Injection](working-with-wheels/dependency-injection.md)
123130
* [Submitting Pull Requests](working-with-wheels/submitting-pull-requests.md)
124131
* [Documenting your Code](working-with-wheels/documenting-your-code.md)
125132

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
description: Live monitoring dashboard for the job queue.
3+
---
4+
5+
# wheels jobs monitor
6+
7+
Display a continuously refreshing dashboard showing queue statistics, throughput metrics, error rates, and recent job activity.
8+
9+
## Usage
10+
11+
```bash
12+
wheels jobs monitor [options]
13+
```
14+
15+
## Options
16+
17+
| Option | Default | Description |
18+
|--------|---------|-------------|
19+
| `--interval` | `3` | Refresh interval in seconds |
20+
| `--queue` | _(all)_ | Filter by queue name |
21+
22+
## Examples
23+
24+
```bash
25+
# Watch the dashboard with default settings
26+
wheels jobs monitor
27+
28+
# Slower refresh rate
29+
wheels jobs monitor --interval=10
30+
31+
# Monitor a specific queue
32+
wheels jobs monitor --queue=mailers
33+
```
34+
35+
## Dashboard Sections
36+
37+
### Queue Summary
38+
Pending, processing, completed, and failed counts across all queues.
39+
40+
### Throughput (last 60 minutes)
41+
- Completed and failed job counts
42+
- Error rate percentage
43+
44+
### Recent Jobs
45+
The 5 most recently updated jobs with status, class, queue, and timestamp.
46+
47+
### Timeout Recovery
48+
If any processing jobs have exceeded their timeout, they are automatically recovered and reported.
49+
50+
## Behavior
51+
52+
- Each refresh cycle calls the Wheels bridge to fetch fresh statistics
53+
- Timed-out jobs (stuck in `processing` longer than 300 seconds) are automatically recovered
54+
- Press `Ctrl+C` to stop monitoring
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
description: Purge old completed or failed jobs from the queue table.
3+
---
4+
5+
# wheels jobs purge
6+
7+
Delete old jobs from the `wheels_jobs` table to prevent table bloat. By default, purges completed jobs older than 7 days.
8+
9+
## Usage
10+
11+
```bash
12+
wheels jobs purge [options]
13+
```
14+
15+
## Options
16+
17+
| Option | Default | Description |
18+
|--------|---------|-------------|
19+
| `--completed` | `true` | Purge completed jobs |
20+
| `--failed` | `false` | Purge failed jobs |
21+
| `--older-than` | `7` | Delete jobs older than this many days |
22+
| `--queue` | _(all)_ | Filter by queue name |
23+
| `--force` | `false` | Skip confirmation prompt |
24+
25+
## Examples
26+
27+
```bash
28+
# Purge completed jobs older than 7 days (default)
29+
wheels jobs purge
30+
31+
# Purge both completed and failed jobs older than 30 days
32+
wheels jobs purge --completed --failed --older-than=30
33+
34+
# Purge only from a specific queue
35+
wheels jobs purge --queue=reports --older-than=14
36+
37+
# Purge failed jobs only
38+
wheels jobs purge --completed=false --failed --older-than=3
39+
```
40+
41+
## Behavior
42+
43+
- Completed jobs are matched by `completedAt` date
44+
- Failed jobs are matched by `failedAt` date
45+
- Pending and processing jobs are never purged
46+
- When both `--completed` and `--failed` are specified, each is purged separately and totals are reported
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
description: Retry failed jobs by resetting them to pending status.
3+
---
4+
5+
# wheels jobs retry
6+
7+
Reset failed jobs back to `pending` status so they will be picked up by the next worker cycle. Resets the attempt counter and clears the error state.
8+
9+
## Usage
10+
11+
```bash
12+
wheels jobs retry [options]
13+
```
14+
15+
## Options
16+
17+
| Option | Default | Description |
18+
|--------|---------|-------------|
19+
| `--queue` | _(all)_ | Filter by queue name |
20+
| `--limit` | `0` | Maximum number of jobs to retry (0 = all) |
21+
22+
## Examples
23+
24+
```bash
25+
# Retry all failed jobs across all queues
26+
wheels jobs retry
27+
28+
# Retry only failed mailer jobs
29+
wheels jobs retry --queue=mailers
30+
31+
# Retry at most 10 failed jobs (oldest first)
32+
wheels jobs retry --limit=10
33+
```
34+
35+
## Behavior
36+
37+
- Sets `status` back to `pending`
38+
- Resets `attempts` to `0`
39+
- Clears `lastError` and `failedAt`
40+
- Sets `runAt` to now (immediate processing)
41+
- When `--limit` is specified, retries the oldest failed jobs first
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
description: Display job queue statistics with per-queue breakdown.
3+
---
4+
5+
# wheels jobs status
6+
7+
Show the current state of the job queue, broken down by queue name and status.
8+
9+
## Usage
10+
11+
```bash
12+
wheels jobs status [options]
13+
```
14+
15+
## Options
16+
17+
| Option | Default | Description |
18+
|--------|---------|-------------|
19+
| `--queue` | _(all)_ | Filter by queue name |
20+
| `--format` | `table` | Output format: `table` or `json` |
21+
22+
## Examples
23+
24+
```bash
25+
# Show all queues in table format
26+
wheels jobs status
27+
28+
# Filter to a specific queue
29+
wheels jobs status --queue=mailers
30+
31+
# JSON output for scripting
32+
wheels jobs status --format=json
33+
```
34+
35+
## Output
36+
37+
The table displays per-queue counts for each status (pending, processing, completed, failed) with a totals row:
38+
39+
```
40+
| Queue | Pending | Processing | Completed | Failed | Total |
41+
|-------------|---------|------------|-----------|--------|-------|
42+
| default | 5 | 1 | 230 | 2 | 238 |
43+
| mailers | 12 | 0 | 89 | 0 | 101 |
44+
| TOTAL | 17 | 1 | 319 | 2 | 339 |
45+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
description: Start a persistent job worker daemon that polls for and processes background jobs.
3+
---
4+
5+
# wheels jobs work
6+
7+
Start a job worker that continuously polls the job queue and processes pending jobs. The worker claims jobs using optimistic locking, making it safe to run multiple workers concurrently.
8+
9+
## Usage
10+
11+
```bash
12+
wheels jobs work [options]
13+
```
14+
15+
## Options
16+
17+
| Option | Default | Description |
18+
|--------|---------|-------------|
19+
| `--queue` | _(all)_ | Comma-delimited queue names to process |
20+
| `--interval` | `5` | Seconds between poll cycles |
21+
| `--max-jobs` | `0` | Stop after processing this many jobs (0 = unlimited) |
22+
| `--timeout` | `300` | Job execution timeout in seconds |
23+
| `--quiet` | `false` | Suppress per-job output, only show errors |
24+
25+
## Examples
26+
27+
```bash
28+
# Process all queues with defaults
29+
wheels jobs work
30+
31+
# Process only mailer and notification queues
32+
wheels jobs work --queue=mailers,notifications
33+
34+
# Fast polling with a job limit
35+
wheels jobs work --interval=2 --max-jobs=500
36+
37+
# Quiet mode for production
38+
wheels jobs work --queue=default --quiet
39+
```
40+
41+
## Concurrency
42+
43+
Run multiple worker processes for parallelism. Each worker independently claims jobs via optimistic locking (`UPDATE WHERE status='pending' AND id=:id`), so no job is processed twice.
44+
45+
```bash
46+
# Terminal 1
47+
wheels jobs work --queue=mailers
48+
49+
# Terminal 2
50+
wheels jobs work --queue=default,reports
51+
```
52+
53+
## Behavior
54+
55+
1. Each poll cycle, the worker calls the Wheels bridge to claim the next pending job
56+
2. If a job is found, it's marked as `processing` and executed
57+
3. On success, the job is marked `completed`; on failure, it's retried with exponential backoff or marked `failed`
58+
4. If no jobs are available, the worker sleeps for `--interval` seconds
59+
5. When a job completes successfully, the worker immediately checks for more work before sleeping

0 commit comments

Comments
 (0)