Included Modules

Class/Module Index [+]

Quicksearch

Chef::Provider::Service::Init

Public Class Methods

new(new_resource, run_context) click to toggle source
# File lib/chef/provider/service/init.rb, line 31
def initialize(new_resource, run_context)
  super
  @init_command = "/etc/init.d/#{@new_resource.service_name}"
end

Public Instance Methods

define_resource_requirements() click to toggle source
# File lib/chef/provider/service/init.rb, line 36
def define_resource_requirements
  # do not call super here, inherit only shared_requirements
  shared_resource_requirements
  requirements.assert(:start, :stop, :restart, :reload) do |a|
    a.assertion { ::File.exist?(@init_command) }
    a.failure_message(Chef::Exceptions::Service, "#{@init_command} does not exist!")
    a.whyrun("Init script '#{@init_command}' doesn't exist, assuming a prior action would have created it.") do
      # blindly assume that the service exists but is stopped in why run mode:
      @status_load_success = false
    end
  end
end
reload_service() click to toggle source
# File lib/chef/provider/service/init.rb, line 77
def reload_service
  if @new_resource.reload_command
    super
  elsif @new_resource.supports[:reload]
    shell_out!("#{@init_command} reload")
  end
end
restart_service() click to toggle source
# File lib/chef/provider/service/init.rb, line 65
def restart_service
  if @new_resource.restart_command
    super
  elsif @new_resource.supports[:restart]
    shell_out!("#{@init_command} restart")
  else
    stop_service
    sleep 1
    start_service
  end
end
start_service() click to toggle source
# File lib/chef/provider/service/init.rb, line 49
def start_service
  if @new_resource.start_command
    super
  else
    shell_out!("#{@init_command} start")
  end
end
stop_service() click to toggle source
# File lib/chef/provider/service/init.rb, line 57
def stop_service
  if @new_resource.stop_command
    super
  else
    shell_out!("#{@init_command} stop")
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.