Class: Upstart

Inherits:
ServiceManager show all
Defined in:
lib/resources/service.rb

Overview

Instance Attribute Summary

Attributes inherited from ServiceManager

#inspec

Instance Method Summary collapse

Methods inherited from ServiceManager

#initialize

Constructor Details

This class inherits a constructor from ServiceManager

Instance Method Details

#info(service_name) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/resources/service.rb', line 160

def info(service_name)
  # get the status of upstart service
  status = inspec.command("initctl status #{service_name}")

  # fallback for systemv services, those are not handled via `initctl`
  return SysV.new(inspec).info(service_name) if status.exit_status.to_i != 0

  # @see: http://upstart.ubuntu.com/cookbook/#job-states
  # grep for running to indicate the service is there
  running = !status.stdout[/running/].nil?

  {
    name: service_name,
    description: nil,
    installed: true,
    running: running,
    enabled: info_enabled(status, service_name),
    type: 'upstart',
  }
end