class PoiseService::ServiceProviders::Upstart
Public Class Methods
default_inversion_options(node, resource)
click to toggle source
@api private
Calls superclass method
# File lib/poise_service/service_providers/upstart.rb, line 37 def self.default_inversion_options(node, resource) super.merge({ # Time to wait between stop and start. restart_delay: 1, }) end
provides_auto?(node, resource)
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 32 def self.provides_auto?(node, resource) service_resource_hints.include?(:upstart) end
Public Instance Methods
action_reload()
click to toggle source
Shim out reload if we have a version that predates reload support.
Calls superclass method
PoiseService::ServiceProviders::Base#action_reload
# File lib/poise_service/service_providers/upstart.rb, line 57 def action_reload return if options['never_reload'] if !upstart_features[:reload_signal] && new_resource.reload_signal != 'HUP' if options[:reload_shim] Process.kill(new_resource.reload_signal, pid) else check_reload_signal! end else super end end
action_restart()
click to toggle source
True restart in Upstart
preserves the original config data, we want the more obvious behavior like everything else in the world that restart would re-read the updated config file. Use stop+start to get this behavior. manpages.ubuntu.com/manpages/raring/man8/initctl.8.html
# File lib/poise_service/service_providers/upstart.rb, line 48 def action_restart return if options['never_restart'] action_stop # Give things a moment to stop before we try starting again. sleep(options['restart_delay']) action_start end
pid()
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 70 def pid cmd = shell_out(%w{initctl status} + [new_resource.service_name]) if !cmd.error? && md = cmd.stdout.match(/process (\d+)/) md[1].to_i else nil end end
Private Instance Methods
check_reload_signal!()
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 128 def check_reload_signal! if !options['reload_shim'] && !upstart_features[:reload_signal] && new_resource.reload_signal != 'HUP' raise Error.new("Upstart #{upstart_version} only supports HUP for reload, to use the shim please set the 'reload_shim' options for #{new_resource.to_s}") end end
create_service()
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 87 def create_service check_reload_signal! # Set features so it will be a closure below. features = upstart_features service_template("/etc/init/#{new_resource.service_name}.conf", 'upstart.conf.erb') do variables.update( upstart_features: features, ) end end
destroy_service()
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 98 def destroy_service file "/etc/init/#{new_resource.service_name}.conf" do action :delete end end
service_resource()
click to toggle source
Calls superclass method
PoiseService::ServiceProviders::Base#service_resource
# File lib/poise_service/service_providers/upstart.rb, line 81 def service_resource super.tap do |r| r.provider(Chef::Provider::Service::Upstart) end end
upstart_features()
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 113 def upstart_features @upstart_features ||= begin upstart_ver = Gem::Version.new(upstart_version) versions_added = { kill_signal: '1.3', reload_signal: '1.10', setuid: '1.4', } versions_added.inject({}) do |memo, (feature, version)| memo[feature] = Gem::Requirement.create(">= #{version}").satisfied_by?(upstart_ver) memo end end end
upstart_version()
click to toggle source
# File lib/poise_service/service_providers/upstart.rb, line 104 def upstart_version cmd = shell_out(%w{initctl --version}) if !cmd.error? && md = cmd.stdout.match(/upstart ([^)]+)\)/) md[1] else '0' end end