class PoiseService::ServiceProviders::Sysvinit
Public Class Methods
provides_auto?(node, resource)
click to toggle source
# File lib/poise_service/service_providers/sysvinit.rb, line 25 def self.provides_auto?(node, resource) [:debian, :redhat, :invokercd].any? {|name| service_resource_hints.include?(name) } end
Public Instance Methods
pid()
click to toggle source
# File lib/poise_service/service_providers/sysvinit.rb, line 29 def pid IO.read(pid_file).to_i if ::File.exist?(pid_file) end
Private Instance Methods
create_service()
click to toggle source
# File lib/poise_service/service_providers/sysvinit.rb, line 56 def create_service # Split the command into the binary and its arguments. This is for # start-stop-daemon since it treats those differently. parts = new_resource.command.split(/ /, 2) daemon = ENV['PATH'].split(/:/) .map {|path| ::File.absolute_path(parts[0], path) } .find {|path| ::File.exist?(path) } || parts[0] # Sigh scoping. pid_file_ = pid_file # Render the service template service_template(script_path, 'sysvinit.sh.erb') do mode '755' variables.update( daemon: daemon, daemon_options: parts[1].to_s, pid_file: pid_file_, pid_file_external: options['pid_file_external'].nil? ? !!options['pid_file'] : options['pid_file_external'], platform_family: node['platform_family'], ) end end
destroy_service()
click to toggle source
# File lib/poise_service/service_providers/sysvinit.rb, line 78 def destroy_service file script_path do action :delete end file pid_file do action :delete end end
pid_file()
click to toggle source
# File lib/poise_service/service_providers/sysvinit.rb, line 92 def pid_file options['pid_file'] || "/var/run/#{new_resource.service_name}.pid" end
script_path()
click to toggle source
# File lib/poise_service/service_providers/sysvinit.rb, line 88 def script_path options['script_path'] || "/etc/init.d/#{new_resource.service_name}" end
service_resource()
click to toggle source
Calls superclass method
PoiseService::ServiceProviders::Base#service_resource
# File lib/poise_service/service_providers/sysvinit.rb, line 35 def service_resource super.tap do |r| r.provider(case node['platform_family'] when 'debian' Chef::Provider::Service::Debian when 'rhel', 'amazon' Chef::Provider::Service::Redhat else # Better than nothing I guess? Will fail on enable I think. Chef::Provider::Service::Init end) r.init_command(script_path) # Pending https://github.com/chef/chef/pull/4709. r.start_command("#{script_path} start") r.stop_command("#{script_path} stop") r.status_command("#{script_path} status") r.restart_command("#{script_path} restart") r.reload_command("#{script_path} reload") end end