Module: Luban::Deployment::Service::Worker::Base
- Included in:
- Application::Worker, Installer, Luban::Deployment::Service::Worker
- Defined in:
- lib/luban/deployment/cli/service/worker.rb
Instance Method Summary collapse
- #control_file_name ⇒ Object
- #control_file_path ⇒ Object
- #log_file_name ⇒ Object
- #log_file_path ⇒ Object
- #log_path ⇒ Object
- #output_redirection(output) ⇒ Object
- #pid_file_name ⇒ Object
- #pid_file_path ⇒ Object
- #pids_path ⇒ Object
- #profile_name ⇒ Object
- #profile_path ⇒ Object
- #service_entry ⇒ Object
- #shell_command(cmd, setup: shell_setup, prefix: shell_prefix, output: shell_output, delimiter: shell_delimiter) ⇒ Object
- #shell_delimiter ⇒ Object
- #shell_output ⇒ Object
- #shell_prefix ⇒ Object
- #shell_setup ⇒ Object
Instance Method Details
#control_file_name ⇒ Object
73 74 75 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 73 def control_file_name @control_file_name ||= "#{service_name}.conf" end |
#control_file_path ⇒ Object
69 70 71 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 69 def control_file_path @control_file_path ||= profile_path.join(control_file_name) end |
#log_file_name ⇒ Object
53 54 55 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 53 def log_file_name @log_file_name ||= "#{service_name}.log" end |
#log_file_path ⇒ Object
49 50 51 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 49 def log_file_path @log_file_path ||= log_path.join(log_file_name) end |
#log_path ⇒ Object
45 46 47 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 45 def log_path @log_path ||= shared_path.join('log') end |
#output_redirection(output) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 18 def output_redirection(output) case output when :stdout "2>&1" when nil "> /dev/null 2>&1" when "" "" else ">> #{output} 2>&1" end end |
#pid_file_name ⇒ Object
65 66 67 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 65 def pid_file_name @pid_file_name ||= "#{service_name}.pid" end |
#pid_file_path ⇒ Object
61 62 63 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 61 def pid_file_path @pid_file_path ||= pids_path.join(pid_file_name) end |
#pids_path ⇒ Object
57 58 59 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 57 def pids_path @pids_path ||= shared_path.join('pids') end |
#profile_name ⇒ Object
35 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 35 def profile_name; service_name; end |
#profile_path ⇒ Object
41 42 43 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 41 def profile_path @profile_path ||= shared_path.join('profile', profile_name) end |
#service_entry ⇒ Object
37 38 39 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 37 def service_entry @service_entry ||= "#{env_name.gsub('/', '.')}.#{profile_name}" end |
#shell_command(cmd, setup: shell_setup, prefix: shell_prefix, output: shell_output, delimiter: shell_delimiter) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 11 def shell_command(cmd, setup: shell_setup, prefix: shell_prefix, output: shell_output, delimiter: shell_delimiter) cmd = "#{prefix.join(' ')} #{cmd}" unless prefix.empty? cmd = "#{setup.join(' ' + delimiter + ' ')} #{delimiter} #{cmd}" unless setup.empty? "#{cmd} #{output_redirection(output)}" end |
#shell_delimiter ⇒ Object
9 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 9 def shell_delimiter; @shell_delimiter ||= ';'; end |
#shell_output ⇒ Object
8 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 8 def shell_output; @shell_output ||= :stdout; end |
#shell_prefix ⇒ Object
7 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 7 def shell_prefix; @shell_prefix ||= []; end |
#shell_setup ⇒ Object
6 |
# File 'lib/luban/deployment/cli/service/worker.rb', line 6 def shell_setup; @shell_setup ||= ["source #{envrc_file}"]; end |