docs/setup.md
This guide consolidates the new guided installer, verification commands, and rollback steps so teams can onboard the engine into either a fresh Rails host or an existing application without missing prerequisites. You never need to clone the SourceMonitor repository for installation—simply add the gem to your host application's Gemfile and run the steps below.
| Requirement | Minimum | Notes |
|---|---|---|
| Ruby | 4.0.1 | Use rbenv and match the engine's .ruby-version. |
| Rails | 8.1.2 | Run bin/rails about inside the host to confirm. |
| PostgreSQL | 14+ | Required for Solid Queue tables and item storage. |
| Node.js | 18+ | Needed for Tailwind/esbuild assets when the host owns node tooling. |
| Background jobs | Solid Queue (>= 0.3, < 3.0) | Add solid_queue to the host Gemfile if not present. |
| Realtime | Solid Cable (>= 3.0) or Redis | Solid Cable is the default; Redis requires config.realtime.adapter = :redis. |
Run these commands inside your host Rails application before invoking the guided workflow:
bundle add source_monitor --version "~> 0.13.0"
# or add gem "source_monitor", "~> 0.13.0" to Gemfile manually
bundle install
This ensures Bundler can load SourceMonitor so the commands below are available.
Check prerequisites (optional but fast):
bin/rails source_monitor:setup:check
This invokes the dependency checker added in Phase 10.04 and surfaces remediation text when versions or adapters are missing.
Run the guided installer:
bin/source_monitor install
/source_monitor).gem "source_monitor" is in the host Gemfile and runs bundle install via rbenv shims.npm install when package.json exists.bin/rails generate source_monitor:install --mount-path=....bin/rails db:migrate.config/initializers/source_monitor.rb with a navigation hint and, when desired, Devise hooks.bin/source_monitor verify).Start background workers:
bin/rails solid_queue:start
The install generator automatically handles all worker configuration:
config/recurring.yml (fetch scheduling, scraping, cleanup).jobs: entry so bin/dev starts Solid Queue alongside the web server.recurring_schedule: config/recurring.yml in config/queue.yml so recurring jobs load on startup.All three steps are idempotent. If any configuration is missing, re-run: bin/rails generate source_monitor:install
Visit the dashboard at the chosen mount path, create a source, and trigger “Fetch Now” to validate realtime updates and Solid Queue processing.
Use --yes to accept defaults (mount path /source_monitor, Devise hooks enabled if Devise detected):
bin/source_monitor install --yes
bin/source_monitor verify
bin/rails source_monitor:setup:verify
SOURCE_MONITOR_SETUP_TELEMETRY=true. Logs append to log/source_monitor_setup.log.Prefer to script each step or plug SourceMonitor into an existing deployment checklist? Use the manual flow below. It mirrors the guided CLI internals while keeping every command explicit.
| Step | Command | Purpose |
|---|---|---|
| 1 | gem "source_monitor", github: "dchuk/source_monitor" | Add the engine to your Gemfile (skip if already present) |
| 2 | bundle install | Install Ruby dependencies |
| 3 | bin/rails generate source_monitor:install --mount-path=/source_monitor | Mount the engine, create the initializer, and configure recurring jobs |
| 4 | bin/rails railties:install:migrations FROM=source_monitor | Copy engine migrations (idempotent) |
| 5 | bin/rails db:migrate | Apply schema updates, including Solid Queue tables |
| 6 | bin/rails solid_queue:start | Ensure jobs process via Solid Queue |
| 6a | Handled by generator (patches Procfile.dev) | Ensure bin/dev starts Solid Queue workers |
| 6b | Handled by generator (patches config/queue.yml) | Wire recurring jobs into Solid Queue dispatcher |
| 7 | bin/jobs --recurring_schedule_file=config/recurring.yml | Start recurring scheduler (optional but recommended) |
| 8 | bin/source_monitor verify | Confirm Solid Queue/Action Cable readiness and emit telemetry |
Tip: You can drop these commands directly into your CI pipeline or release scripts. The CLI uses the same services, so mixing and matching is safe.
Gemfile (GitHub edge or released version) and run bundle install. If your host manages node tooling, run npm install also.bin/rails generate source_monitor:install --mount-path=/source_monitor. The generator mounts the engine, creates config/initializers/source_monitor.rb, and configures recurring Solid Queue jobs in config/recurring.yml. Re-running the generator is safe; it detects existing mounts/initializers and skips entries that are already present.bin/rails railties:install:migrations FROM=source_monitor. This brings in the SourceMonitor tables plus Solid Cable/Queue schema when needed. The command is idempotent—run it again after upgrading the gem.bin/rails db:migrate. If your host already installed Solid Queue migrations manually, delete duplicate files before migrating.ApplicationCable::Connection/Channel exist and that config/initializers/source_monitor.rb uses the adapter you expect. To switch to Redis, set config.realtime.adapter = :redis and config.realtime.redis_url.bin/rails solid_queue:start (or your process manager). The install generator automatically configures recurring jobs in config/recurring.yml for fetch scheduling, scraping, and cleanup. They'll run with bin/dev or bin/jobs.
Procfile.dev with a jobs: entry for Solid Queue. Verify the file contains jobs: bundle exec rake solid_queue:start after running the generator.config/queue.yml dispatchers with recurring_schedule: config/recurring.yml. Verify the key is present after running the generator.bin/source_monitor verify to ensure Solid Queue workers and Action Cable are healthy, then visit the mount path to trigger a fetch manually. Enable telemetry if you want JSON logs recorded for support.| Host Scenario | Status | Notes |
|---|---|---|
| Rails 8 full-stack app | ✅ Supported | Use the guided workflow or the manual generator steps above |
Rails 8 API-only app (--api) | ✅ Supported | Generator mounts engine; provide your own UI entry point if needed |
| Dedicated Solid Queue database | ✅ Supported | Run bin/rails solid_queue:install in the host app before copying SourceMonitor migrations |
| Redis-backed Action Cable | ✅ Supported | Set config.realtime.adapter = :redis and provide config.realtime.redis_url; existing config/cable.yml entries are preserved |
If you need to revert the integration in a host app:
gem "source_monitor" from the host Gemfile and rerun bundle install.config/initializers/source_monitor.rb) and any navigation links referencing the mount path.config/routes.rb (the install generator adds a comment to help locate it).bin/rails db:migrate:down VERSION=<timestamp> # repeat for each engine migration
Document each removal in the host application's changelog to keep future upgrades predictable.
Add a guardrail test in the host app (or dummy) to make sure authentication protects the dashboard after upgrades:
# test/system/source_monitor_setup_test.rb
require "application_system_test_case"
class SourceMonitorSetupTest < ApplicationSystemTestCase
test "signed in admin can reach SourceMonitor" do
user = users(:admin)
sign_in user
visit "/source_monitor"
assert_text "SourceMonitor Dashboard"
end
end
sign_in user for your Devise helper (login_as, etc.).authorize_with hook.bin/source_monitor install is idempotent: if migrations already exist or Devise hooks are present, the workflow skips creation and only re-verifies prerequisites.bin/source_monitor verify directly after migrations to catch worker/cable misconfigurations before deploying.tasks/prd-setup-workflow-streamlining.md) and active task list (tasks/tasks-setup-workflow-streamlining.md).