Module: Capistrano::SidekiqCommon
- Included in:
- Capistrano::Sidekiq::Systemd
- Defined in:
- lib/capistrano/sidekiq.rb
Instance Method Summary collapse
- #compiled_template(config_file = "sidekiq.yml") ⇒ Object
- #expanded_bundle_path ⇒ Object
- #sidekiq_config ⇒ Object
- #sidekiq_user(role = nil) ⇒ Object
- #switch_user(role, &block) ⇒ Object
Instance Method Details
#compiled_template(config_file = "sidekiq.yml") ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/capistrano/sidekiq.rb', line 8 def compiled_template(config_file = "sidekiq.yml") @config_file = config_file local_template_directory = fetch(:sidekiq_service_templates_path) search_paths = [ File.join(local_template_directory, 'sidekiq.service.capistrano.erb'), File.( File.join(*%w[.. templates sidekiq.service.capistrano.erb]), __FILE__ ) ] template_path = search_paths.detect { |path| File.file?(path) } template = File.read(template_path) ERB.new(template, trim_mode: '-').result(binding) end |
#expanded_bundle_path ⇒ Object
23 24 25 |
# File 'lib/capistrano/sidekiq.rb', line 23 def backend.capture(:echo, SSHKit.config.command_map[:bundle]).strip end |
#sidekiq_config ⇒ Object
27 28 29 |
# File 'lib/capistrano/sidekiq.rb', line 27 def sidekiq_config "--config config/#{@config_file}" if @config_file != "sidekiq.yml" end |
#sidekiq_user(role = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/capistrano/sidekiq.rb', line 40 def sidekiq_user(role = nil) if role.nil? fetch(:sidekiq_user) else properties = role.properties properties.fetch(:sidekiq_user) || # local property for sidekiq only fetch(:sidekiq_user) || properties.fetch(:run_as) || # global property across multiple capistrano gems role.user end end |
#switch_user(role, &block) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/capistrano/sidekiq.rb', line 31 def switch_user(role, &block) su_user = sidekiq_user(role) if su_user == role.user yield else as su_user, &block end end |