Class: Capistrano::Sidekiq::Systemd
- Inherits:
-
Plugin
- Object
- Plugin
- Capistrano::Sidekiq::Systemd
- Includes:
- Capistrano::SidekiqCommon
- Defined in:
- lib/capistrano/sidekiq/systemd.rb
Instance Method Summary collapse
- #define_tasks ⇒ Object
- #execute_systemd(*args) ⇒ Object
- #set_defaults ⇒ Object
- #sudo_if_needed(*command) ⇒ Object
- #systemd_command(*args) ⇒ Object
Methods included from Capistrano::SidekiqCommon
#compiled_template, #expanded_bundle_path, #sidekiq_config, #sidekiq_user, #switch_user
Instance Method Details
#define_tasks ⇒ Object
6 7 8 |
# File 'lib/capistrano/sidekiq/systemd.rb', line 6 def define_tasks eval_rakefile File.('../tasks/systemd.rake', __dir__) end |
#execute_systemd(*args) ⇒ Object
42 43 44 |
# File 'lib/capistrano/sidekiq/systemd.rb', line 42 def execute_systemd(*args) sudo_if_needed(*systemd_command(*args)) end |
#set_defaults ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/capistrano/sidekiq/systemd.rb', line 9 def set_defaults set_if_empty :systemctl_bin, '/bin/systemctl' set_if_empty :service_unit_user, :user set_if_empty :systemctl_user, fetch(:service_unit_user, :user) == :user set_if_empty :sidekiq_service_unit_name, -> { "#{fetch(:application)}_sidekiq_#{fetch(:stage)}" } set_if_empty :sidekiq_lingering_user, -> { fetch(:lingering_user, fetch(:user)) } ## Sidekiq could have a stripped down or more complex version of the environment variables set_if_empty :sidekiq_service_unit_env_files, -> { fetch(:service_unit_env_files, []) } set_if_empty :sidekiq_service_unit_env_vars, -> { fetch(:service_unit_env_vars, []) } set_if_empty :sidekiq_service_templates_path, fetch(:service_templates_path, 'config/deploy/templates') end |
#sudo_if_needed(*command) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/capistrano/sidekiq/systemd.rb', line 34 def sudo_if_needed(*command) if fetch(:service_unit_user) == :system backend.sudo command.map(&:to_s).join(" ") else backend.execute(*command) end end |
#systemd_command(*args) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/capistrano/sidekiq/systemd.rb', line 24 def systemd_command(*args) command = [fetch(:systemctl_bin)] unless fetch(:service_unit_user) == :system command << "--user" end command + args end |