Class: PoiseService::ServiceProviders::Upstart

Inherits:
Base
  • Object
show all
Includes:
Chef::Mixin::ShellOut
Defined in:
lib/poise_service/service_providers/upstart.rb

Overview

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#action_disable, #action_enable, #action_start, #action_stop, service_resource_hints

Class Method Details

.provides_auto?(node, resource) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 1.0.0



32
33
34
35
36
# File 'lib/poise_service/service_providers/upstart.rb', line 32

def self.provides_auto?(node, resource)
  # Don't allow upstart under docker, it won't work.
  return false if node['virtualization'] && %w{docker lxc}.include?(node['virtualization']['system'])
  service_resource_hints.include?(:upstart)
end

Instance Method Details

#action_reloadObject

Shim out reload if we have a version that predates reload support.

Since:

  • 1.0.0



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/poise_service/service_providers/upstart.rb', line 49

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_restartObject

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. http://manpages.ubuntu.com/manpages/raring/man8/initctl.8.html

Since:

  • 1.0.0



42
43
44
45
46
# File 'lib/poise_service/service_providers/upstart.rb', line 42

def action_restart
  return if options['never_restart']
  action_stop
  action_start
end

#pidObject

Since:

  • 1.0.0



62
63
64
65
66
67
68
69
# File 'lib/poise_service/service_providers/upstart.rb', line 62

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