Class: Silas::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/silas/doctor.rb

Overview

One command for every known first-run failure mode: provider key, queue adapter, model resolution, migrations, tool validation, the rescuer entry, cable adapter for live streaming, and auth wiring. Each check was already written somewhere in the codebase — this makes them reachable as bin/rails silas:doctor.

Defined Under Namespace

Classes: Check

Constant Summary collapse

ASYNC_QUEUE_REMEDY =

Rails defaults development to :async, which the queue_adapter check below FAILS — so a stock app fails the doctor the installer told it to run. The remedy travels with the failure, and the install generator prints this same constant when it detects :async, so the two surfaces can't drift. Printed, never written: database.yml and cable.yml belong to the host app.

<<~MSG.freeze
  Add to config/environments/development.rb:

      config.active_job.queue_adapter = :solid_queue
      config.solid_queue.connects_to = { database: { writing: :queue } }

  and a queue database to config/database.yml (SQLite shown — drop the
  connects_to line above if Solid Queue shares your primary database):

      development:
        primary:
          <<: *default
          database: storage/development.sqlite3
        queue:
          <<: *default
          database: storage/development_queue.sqlite3
          migrations_paths: db/queue_migrate

  Then `bin/rails db:prepare`, and run the worker next to the server:
  `bin/jobs`. On an app that predates Rails 8, `bundle add solid_queue &&
  bin/rails solid_queue:install` first. For scripts and demos `:inline` is
  also safe — synchronous, no durability.
MSG

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:) ⇒ Doctor

Returns a new instance of Doctor.



44
45
46
# File 'lib/silas/doctor.rb', line 44

def initialize(root:)
  @root = Pathname(root)
end

Class Method Details

.run(root: Rails.root) ⇒ Object



42
# File 'lib/silas/doctor.rb', line 42

def self.run(root: Rails.root) = new(root: root).run

Instance Method Details

#runObject



48
49
50
51
52
53
# File 'lib/silas/doctor.rb', line 48

def run
  [
    provider_credentials, queue_adapter, model_resolution, migrations,
    agent_directory, rescuer_entry, streaming_cable, auth_wiring
  ].flatten.compact
end