Class: Chef::Provider::Service::ChefContainer

Inherits:
Chef::Provider::Service show all
Includes:
Container::Runit
Defined in:
lib/chef/provider/service/chef_container.rb

Instance Attribute Summary

Attributes included from Container::Runit

#service_dir, #sv_bin, #sv_dir

Instance Method Summary collapse

Methods included from Container::Runit

#default_log_dir, #log_dir, #log_run_script, #log_run_script_content, #run_script, #run_script_content, #setup

Instance Method Details

#disable_serviceObject



53
54
55
56
57
# File 'lib/chef/provider/service/chef_container.rb', line 53

def disable_service
shell_out("#{@sv_bin} down #{service_dir_name}")
Chef::Log.debug("#{new_resource} down")
FileUtils.rm(service_dir_name)
Chef::Log.debug("#{new_resource} service symlink removed")end

#enable_serviceObject

Override Service Actions



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chef/provider/service/chef_container.rb', line 36

def enable_service
  Chef::Log.debug("Creating symlink in service_dir for #{new_resource.service_name}")
  service_link.run_action(:create)

  Chef::Log.debug("waiting until named pipe #{service_dir_name}/supervise/ok exists.")
  until ::FileTest.pipe?("#{service_dir_name}/supervise/ok")
    sleep 1
    Chef::Log.debug('.')
  end

  Chef::Log.debug("waiting until named pipe #{service_dir_name}/log/supervise/ok exists.")
  until ::FileTest.pipe?("#{service_dir_name}/log/supervise/ok")
    sleep 1
    Chef::Log.debug('.')
  end
end

#reload_serviceObject



71
72
73
# File 'lib/chef/provider/service/chef_container.rb', line 71

def reload_service
  shell_out!("#{@sv_bin} force-reload #{service_dir_name}")
end

#restart_serviceObject



67
68
69
# File 'lib/chef/provider/service/chef_container.rb', line 67

def restart_service
  shell_out!("#{@sv_bin} restart #{service_dir_name}")
end

#service_dir_nameObject



83
84
85
# File 'lib/chef/provider/service/chef_container.rb', line 83

def service_dir_name 
  ::File.join(@service_dir, new_resource.service_name)
end

Helper Resources



91
92
93
94
95
96
# File 'lib/chef/provider/service/chef_container.rb', line 91

def service_link
  return @service_link unless @service_link.nil?
  @service_link = Chef::Resource::Link.new(::File.join(service_dir_name), run_context)
  @service_link.to(sv_dir_name)
  @service_link
end

#start_serviceObject



59
60
61
# File 'lib/chef/provider/service/chef_container.rb', line 59

def start_service
  shell_out!("#{@sv_bin} start #{service_dir_name}")
end

#stop_serviceObject



63
64
65
# File 'lib/chef/provider/service/chef_container.rb', line 63

def stop_service
  shell_out!("#{@sv_bin} stop #{service_dir_name}")
end

#sv_dir_nameObject

Helper Resource Methods



79
80
81
# File 'lib/chef/provider/service/chef_container.rb', line 79

def sv_dir_name
  ::File.join(@sv_dir, new_resource.service_name)
end