Files

Class/Module Index [+]

Quicksearch

Chef::Resource::Service

Public Class Methods

new(name, run_context=nil) click to toggle source
# File lib/chef/resource/service.rb, line 30
def initialize(name, run_context=nil)
  super
  @resource_name = :service
  @service_name = name
  @enabled = nil
  @running = nil
  @parameters = nil
  @pattern = service_name
  @start_command = nil
  @stop_command = nil
  @status_command = nil
  @restart_command = nil
  @reload_command = nil
  @init_command = nil
  @priority = nil
  @timeout = nil
  @action = "nothing"
  @supports = { :restart => false, :reload => false, :status => false }
  @allowed_actions.push(:enable, :disable, :start, :stop, :restart, :reload)

  if(run_context && run_context.node[:init_package] == "systemd")
    @provider = Chef::Provider::Service::Systemd
  end
end

Public Instance Methods

enabled(arg=nil) click to toggle source

if the service is enabled or not

# File lib/chef/resource/service.rb, line 130
def enabled(arg=nil)
  set_or_return(
    :enabled,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
init_command(arg=nil) click to toggle source

The path to the init script associated with the service. On many distributions this is ‘/etc/init.d/SERVICE_NAME’ by default. In non-standard configurations setting this value will save having to specify overrides for the start_command, stop_command and restart_command attributes.

# File lib/chef/resource/service.rb, line 121
def init_command(arg=nil)
  set_or_return(
    :init_command,
    arg,
    :kind_of => [ String ]
  )
end
parameters(arg=nil) click to toggle source
# File lib/chef/resource/service.rb, line 174
def parameters(arg=nil)
  set_or_return(
    :parameters,
    arg,
    :kind_of => [ Hash ]
  )
end
pattern(arg=nil) click to toggle source

regex for match against ps -ef when !supports && status == nil

# File lib/chef/resource/service.rb, line 64
def pattern(arg=nil)
  set_or_return(
    :pattern,
    arg,
    :kind_of => [ String ]
  )
end
priority(arg=nil) click to toggle source

Priority arguments can have two forms:

  • a simple number, in which the default start runlevels get that as the start value and stop runlevels get 100 - value.

  • a hash like { 2 => [:start, 20], 3 => [:stop, 55] }, where the service will be marked as started with priority 20 in runlevel 2, stopped in 3 with priority 55 and no symlinks or similar for other runlevels

# File lib/chef/resource/service.rb, line 157
def priority(arg=nil)
  set_or_return(
    :priority,
    arg,
    :kind_of => [ Integer, String, Hash ]
  )
end
reload_command(arg=nil) click to toggle source
# File lib/chef/resource/service.rb, line 108
def reload_command(arg=nil)
  set_or_return(
    :reload_command,
    arg,
    :kind_of => [ String ]
  )
end
restart_command(arg=nil) click to toggle source

command to call to restart service

# File lib/chef/resource/service.rb, line 100
def restart_command(arg=nil)
  set_or_return(
    :restart_command,
    arg,
    :kind_of => [ String ]
  )
end
running(arg=nil) click to toggle source

if the service is running or not

# File lib/chef/resource/service.rb, line 139
def running(arg=nil)
  set_or_return(
    :running,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
service_name(arg=nil) click to toggle source
# File lib/chef/resource/service.rb, line 55
def service_name(arg=nil)
  set_or_return(
    :service_name,
    arg,
    :kind_of => [ String ]
  )
end
start_command(arg=nil) click to toggle source

command to call to start service

# File lib/chef/resource/service.rb, line 73
def start_command(arg=nil)
  set_or_return(
    :start_command,
    arg,
    :kind_of => [ String ]
  )
end
status_command(arg=nil) click to toggle source

command to call to get status of service

# File lib/chef/resource/service.rb, line 91
def status_command(arg=nil)
  set_or_return(
    :status_command,
    arg,
    :kind_of => [ String ]
  )
end
stop_command(arg=nil) click to toggle source

command to call to stop service

# File lib/chef/resource/service.rb, line 82
def stop_command(arg=nil)
  set_or_return(
    :stop_command,
    arg,
    :kind_of => [ String ]
  )
end
supports(args={}) click to toggle source
# File lib/chef/resource/service.rb, line 182
def supports(args={})
  if args.is_a? Array
    args.each { |arg| @supports[arg] = true }
  elsif args.any?
    @supports = args
  else
    @supports
  end
end
timeout(arg=nil) click to toggle source

timeout only applies to the windows service manager

# File lib/chef/resource/service.rb, line 166
def timeout(arg=nil)
  set_or_return(
    :timeout,
    arg,
    :kind_of => Integer
  )
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.