In a Rails 8.1 app on Solid Queue, how do you add the Mission Control Jobs dashboard, and how is it protected by default?
answer
- a separate gem, not in rails new
- mount MissionControl::Jobs::Engine
- HTTP basic auth, enabled and closed
- credentials under mission_control:
- base_controller_class for your own login
basics
~20 sAdd the mission_control-jobs gem and mount MissionControl::Jobs::Engine in config/routes.rb. It ships with HTTP basic authentication enabled and closed: until credentials are configured every request gets 401, and base_controller_class lets it use your app's own login instead.
solid answer
~40 sMission Control Jobs is a separate gem (`mission_control-jobs`, 1.3 at this pin); `rails new` does not add it. You mount it with `mount MissionControl::Jobs::Engine, at: "/jobs"`. It comes with **HTTP basic authentication enabled and closed**: the user and password are read from credentials under `mission_control:` (`http_basic_auth_user`, `http_basic_auth_password`), `bin/rails mission_control:jobs:authentication:configure` writes them, and with none configured every request gets `401 Unauthorized`. To use your app's own sign-in, set `config.mission_control.jobs.base_controller_class = "AdminController"` (it extends `ApplicationController` by default) and turn basic auth off with `http_basic_auth_enabled = false`, or wrap the mount in a route constraint. The dashboard lists queues and their jobs by status, pauses queues, shows workers and what they run, and retries or discards failed jobs; the same operations exist in the console through `ActiveJob.jobs`.
go deeper
Know that Mission Control Jobs is a separate gem whose dashboard you mount in routes, and that it needs credentials before it opens.
Explain the closed-by-default basic auth, where credentials live, and how base_controller_class or a route constraint replaces it.
Lock the dashboard behind real admin authorisation, filter sensitive arguments, and use the console API for bulk incident work.
Decide who may retry or discard jobs in production and how those operational actions are audited.
## What Mission Control Jobs is **Mission Control Jobs** is a Rails engine that puts a web dashboard and a console API on top of Active Job backends. It supports **Solid Queue** (version 1.0.1 or later) and Resque, and what it can show depends on what the backend offers. It is a **separate gem**: a new Rails 8.1 app gets Solid Queue but not this dashboard. ## Installing and mounting it ```ruby # Gemfile gem "mission_control-jobs" # config/routes.rb Rails.application.routes.draw do mount MissionControl::Jobs::Engine, at: "/jobs" end ``` After that, `/jobs` serves the engine, but only to someone who gets past its authentication. ## Protected by default The gem ships with **HTTP basic authentication enabled and closed**: 1. Its controllers run a `before_action` that checks basic auth while `http_basic_auth_enabled` is true, which is the default. 2. The expected user and password come from the app's encrypted credentials: ```yaml mission_control: http_basic_auth_user: ops http_basic_auth_password: <a long random secret> ``` 3. `bin/rails mission_control:jobs:authentication:configure` writes them for you; prefix `RAILS_ENV=production` to target production credentials. 4. If **no credentials are configured**, every request is answered `401 Unauthorized`. Mounting the engine never exposes jobs by accident. ## Using your app's own login instead Basic auth is a shared secret. Once the platform has real admin accounts, there are two cleaner options: - **A base controller.** Mission Control's controllers extend the host app's `ApplicationController` unless told otherwise. Point them at a controller that already requires an admin and switch basic auth off: ```ruby config.mission_control.jobs.base_controller_class = "AdminController" config.mission_control.jobs.http_basic_auth_enabled = false ``` - **A route constraint** around the `mount`, so requests that fail the check never reach the engine; with sessions from Rails' authentication generator the constraint can look up the session cookie and check the user. Inside the engine its own route helpers win, so a `before_action` in your base controller that redirects to your login page should use the app's helpers, through `main_app.` where names collide (such as `root_path`). ## What you can do with it | Task | Dashboard | Console | |---|---|---| | See queues and their sizes | Queues tab | `ActiveJob.jobs.pending.where(queue_name: "digests")` | | Inspect failed jobs | Failed jobs tab | `ActiveJob.jobs.failed` | | Retry or discard failed jobs | per job or in bulk | `retry_all`, `discard_all` | | See running jobs and workers | In progress and Workers tabs | `ActiveJob.jobs.in_progress` | Queues can also be paused and resumed from the Queues tab, which stops workers from taking jobs from them without touching `queue.yml`. The console helpers come from the querying API the gem adds to Active Job: in `bin/rails console`, `jobs_help` explains how to `connect_to` a job server when there are several. Only failed jobs can be retried; `discard_all` also works on pending jobs, which is a destructive operation kept out of the UI. ## A production checklist - Mount it under an admin-only path and decide on **one** gate: basic auth with strong credentials, a base controller, or a route constraint. - Turn basic auth off explicitly when you switch to your own login, so you do not end up with two prompts. - Hide sensitive job arguments before anyone opens the failed-jobs page. - Treat bulk retry as an incident action: fix the bug first, then retry, because a retried job runs the same code again. ## Settings worth knowing - `filter_arguments` hides chosen top-level argument keys in the UI, useful when jobs receive subscriber email addresses or tokens. - `internal_query_count_limit` caps counts (500,000 by default) so large tables stay responsive. - `scheduled_job_delay_threshold` (one minute by default) decides when a scheduled job is shown as delayed. - `adapters` defaults to the app's `active_job.queue_adapter`.
- Why might a team prefer a route constraint over base_controller_class for Mission Control?A constraint rejects unauthorised requests before they reach the engine, so none of Mission Control's controller code runs for them, and it keeps the authorisation rule in `config/routes.rb` next to the mount. A base controller runs inside the engine, where its route helpers take precedence over the app's, which complicates redirects to the app's login page.
- How do you retry every failed DigestEmailJob from the console after fixing a bug?In `bin/rails console`, with Mission Control installed, run `ActiveJob.jobs.failed.where(job_class_name: "DigestEmailJob").retry_all`. Retrying works only on failed jobs; each retried job is enqueued again and passes through the normal queue, including any concurrency limits.
- rails new installs Mission Control Jobs alongside Solid Queue
- Mounting the engine without credentials leaves the dashboard open
- Mission Control can retry pending jobs as well as failed ones
- base_controller_class alone also turns off the basic auth prompt
- Mission Control stores its own copy of every job in a separate table