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



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/resources/service.rb', line 209

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