Class: Capistrano::SolidQueue::Systemd

Inherits:
Plugin
  • Object
show all
Defined in:
lib/capistrano/solid_queue.rb

Instance Method Summary collapse

Instance Method Details

#define_tasksObject



16
17
18
# File 'lib/capistrano/solid_queue.rb', line 16

def define_tasks
  eval_rakefile File.expand_path("../tasks/solid_queue.rake", __FILE__)
end

#execute_systemd(*args, raise_on_non_zero_exit: true) ⇒ Object



27
28
29
30
# File 'lib/capistrano/solid_queue.rb', line 27

def execute_systemd(*args, raise_on_non_zero_exit: true)
  command = ["/bin/systemctl", "--user"] + args
  backend.execute(*command, raise_on_non_zero_exit: raise_on_non_zero_exit)
end

#fetch_systemd_unit_pathObject



32
33
34
35
36
37
38
39
# File 'lib/capistrano/solid_queue.rb', line 32

def fetch_systemd_unit_path
  if fetch(:solid_queue_systemctl_user) == :system
    "/etc/systemd/system/"
  else
    home_dir = backend.capture :pwd
    File.join(home_dir, ".config", "systemd", "user")
  end
end

#register_hooksObject



20
21
22
23
24
25
# File 'lib/capistrano/solid_queue.rb', line 20

def register_hooks
  after "deploy:starting", "solid_queue:quiet"
  after "deploy:updated", "solid_queue:stop"
  after "deploy:published", "solid_queue:start"
  after "deploy:failed", "solid_queue:restart"
end

#set_defaultsObject



8
9
10
11
12
13
14
# File 'lib/capistrano/solid_queue.rb', line 8

def set_defaults
  set_if_empty :solid_queue_role, "db"
  set_if_empty :solid_queue_access_log, -> { File.join(shared_path, "log", "solid_queue.log") }
  set_if_empty :solid_queue_error_log, -> { File.join(shared_path, "log", "solid_queue.log") }
  set_if_empty :solid_queue_service_unit_name, -> { "#{fetch(:application)}_solid_queue_#{fetch(:stage)}" }
  set_if_empty :solid_queue_systemd_conf_dir, -> { fetch_systemd_unit_path }
end