Class: Wurk::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Wurk::Generators::InstallGenerator
- Defined in:
- lib/generators/wurk/install/install_generator.rb
Overview
bin/rails g wurk:install
Writes a config initializer and adds a commented-out mount line to routes.
The host app picks the mount path; the generator suggests /wurk.
Reads Gemfile.lock and Procfile to print what a Sidekiq app must change;
it edits neither.
Constant Summary collapse
- SIDEKIQ_TIERS =
Sidekiq's own tiers depend on
sidekiqtoo, but the swap removes them. %w[sidekiq sidekiq-pro sidekiq-ent].freeze
- SIDEKIQ_COMMAND =
/\bsidekiq(?:swarm)?\b/
Instance Method Summary collapse
- #copy_initializer ⇒ Object
- #insert_mount_line ⇒ Object
- #show_next_steps ⇒ Object
- #show_procfile_runner ⇒ Object
- #show_shim_line ⇒ Object
Instance Method Details
#copy_initializer ⇒ Object
21 22 23 |
# File 'lib/generators/wurk/install/install_generator.rb', line 21 def copy_initializer template 'wurk.rb', 'config/initializers/wurk.rb' end |
#insert_mount_line ⇒ Object
25 26 27 |
# File 'lib/generators/wurk/install/install_generator.rb', line 25 def insert_mount_line route(%(# mount Wurk::Engine => "/wurk" # uncomment to expose the Wurk dashboard)) end |
#show_next_steps ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/wurk/install/install_generator.rb', line 50 def show_next_steps say <<~STEPS Next steps: 1. Set the queue adapter if you use Active Job: config.active_job.queue_adapter = :wurk 2. Start workers: bundle exec wurkswarm (or bundle exec wurk for one process) 3. To use the dashboard, uncomment the mount line in config/routes.rb. It has no login of its own, so put it behind authentication first: docs/authentication.md in the wurk gem's repository STEPS end |
#show_procfile_runner ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/generators/wurk/install/install_generator.rb', line 41 def show_procfile_runner lines = procfile_sidekiq_lines return if lines.empty? say "\nProcfile worker lines keep working: wurk ships the sidekiq and sidekiqswarm commands." lines.each { |line| say " #{line}" } say 'For one process per core, run `bundle exec wurkswarm` with the same flags.' end |
#show_shim_line ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/wurk/install/install_generator.rb', line 29 def show_shim_line dependents = sidekiq_dependents return if dependents.empty? say <<~SHIM #{dependents.join(', ')} #{dependents.size == 1 ? 'depends' : 'depend'} on the sidekiq gem, which would load real Sidekiq next to Wurk. Keep #{dependents.size == 1 ? 'it' : 'them'} by adding the shim to the Gemfile, in place of gem "sidekiq": gem "sidekiq", github: "developerz-ai/wurk", tag: "v#{Wurk::VERSION}", glob: "ecosystem/sidekiq-shim/*.gemspec" SHIM end |