Sha256: 9019051bb95aa811095b0b756e7b1741e5093735ae6f305c44c80d0e125fb20b
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
class Recipes::BackgroundProcessor < Rails::AppBuilder def ask response = if selected?(:email_service, :none) answer(:background_processor) do Ask.confirm("Do you want to use Sidekiq for background job processing?") end else info "Note: Emails should be sent on background jobs. We'll install sidekiq" true end set(:background_processor, response) end def create add_sidekiq if get(:background_processor) end def install ask heroku = load_recipe(:heroku) set(:heroku, heroku.installed?) create end def installed? gem_exists?(/sidekiq/) end def add_sidekiq gather_gem("sidekiq") add_adapters("sidekiq") add_readme_section :internal_dependencies, :sidekiq edit_procfile("bundle exec sidekiq") append_to_file(".env.development", "DB_POOL=25\n") template("../assets/sidekiq.rb.erb", "config/initializers/sidekiq.rb", force: true) copy_file("../assets/sidekiq.yml", "config/sidekiq.yml", force: true) copy_file("../assets/redis.yml", "config/redis.yml", force: true) insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do <<-HERE.gsub(/^ {6}/, '') mount Sidekiq::Web => '/queue' HERE end end def edit_procfile(cmd) gsub_file("Procfile", /^.*$/m) { |match| "#{match}worker: #{cmd}" } if selected?(:heroku) end def add_adapters(name) application("config.active_job.queue_adapter = :#{name}") application "config.active_job.queue_adapter = :inline", env: "development" application "config.active_job.queue_adapter = :test", env: "test" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
potassium-5.1.2 | lib/potassium/recipes/background_processor.rb |