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

Instance Method Details

#control_file_nameObject



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_pathObject



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_nameObject



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_pathObject



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_pathObject



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_nameObject



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_pathObject



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_pathObject



57
58
59
# File 'lib/luban/deployment/cli/service/worker.rb', line 57

def pids_path
  @pids_path ||= shared_path.join('pids')
end

#profile_nameObject



35
# File 'lib/luban/deployment/cli/service/worker.rb', line 35

def profile_name; service_name; end

#profile_pathObject



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_entryObject



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_delimiterObject



9
# File 'lib/luban/deployment/cli/service/worker.rb', line 9

def shell_delimiter; @shell_delimiter ||= ';'; end

#shell_outputObject



8
# File 'lib/luban/deployment/cli/service/worker.rb', line 8

def shell_output; @shell_output ||= :stdout; end

#shell_prefixObject



7
# File 'lib/luban/deployment/cli/service/worker.rb', line 7

def shell_prefix; @shell_prefix ||= []; end

#shell_setupObject



6
# File 'lib/luban/deployment/cli/service/worker.rb', line 6

def shell_setup; @shell_setup ||= ["source #{envrc_file}"]; end