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

Class Method Details

.provides_auto?(node, resource) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 1.0.0



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

def self.provides_auto?(node, resource)
  service_resource_hints.include?(:upstart)
end

Instance Method Details

#action_reload ⇒ Object

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

Since:

  • 1.0.0



57
58
59
60
61
62
63
64
65
66
67
68
# 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 ⇒ Object

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



48
49
50
51
52
53
54
# 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 ⇒ Object

Since:

  • 1.0.0



70
71
72
73
74
75
76
77
# 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