Job Mode
Job Mode lets you run a Playground as a headless, one-shot task runner instead of an interactive environment.
Instead of a long-lived development workspace, a Job Mode Playground:
- Starts containers
- Runs a designated "watched" service to completion
- Captures the result
- Self-destructs
This is perfect for: running test suites, data migrations, build pipelines, or any automated task that doesn't need a human in the loop.
Enabling Job Mode
Set job_mode: true when creating a Playground via the API:
POST /api/playgrounds
{
"playground": {
"playspec_id": 42,
"playroom_id": 1,
"job_mode": true,
"watched_services": ["tests"]
}
}
Watched Services
The watched_services array lists the container services that Job Mode tracks. When all watched services exit, the Playground is:
- Marked as complete
- Job result (exit code + tail logs) is captured and stored
- Playground is automatically destroyed — no idle costs
If no watched_services are specified, all dynamic services are watched.
Short TTL
Job Mode Playgrounds automatically use a much shorter Time-To-Live (TTL) compared to interactive Playgrounds — typically 1 hour vs. the standard 8 hours. This protects against runaway tasks.
Accessing Results
Once complete, the job result is accessible via the API:
GET /api/playgrounds/:id/job_result
Response:
{
"exit_code": 0,
"completed_at": "2024-01-15T10:35:00Z",
"tail_logs": "...\nAll 42 tests passed."
}
Use Cases
| Use Case | Example |
|---|---|
| Test runner | Run rspec on a feature branch |
| Database migration | Run rails db:migrate in production parity |
| Build pipeline | Build and push a Docker image |
| Documentation generation | Run bundle exec yard and upload docs |
| Code quality | Run linters, security scans, coverage reports |