Class: Itamae::Resource::Service

Inherits:
Base
  • Object
show all
Defined in:
lib/itamae/resource/service.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated

Instance Method Summary collapse

Methods inherited from Base

#action_nothing, define_attribute, inherited, #initialize, #resource_type, #run

Constructor Details

This class inherits a constructor from Itamae::Resource::Base

Instance Method Details

#action_disable(options) ⇒ Object


51
52
53
# File 'lib/itamae/resource/service.rb', line 51

def action_disable(options)
  run_specinfra(:disable_service, attributes.name)
end

#action_enable(options) ⇒ Object


47
48
49
# File 'lib/itamae/resource/service.rb', line 47

def action_enable(options)
  run_specinfra(:enable_service, attributes.name)
end

#action_reload(options) ⇒ Object


43
44
45
# File 'lib/itamae/resource/service.rb', line 43

def action_reload(options)
  run_specinfra(:reload_service, attributes.name)
end

#action_restart(options) ⇒ Object


39
40
41
# File 'lib/itamae/resource/service.rb', line 39

def action_restart(options)
  run_specinfra(:restart_service, attributes.name)
end

#action_start(options) ⇒ Object


27
28
29
30
31
# File 'lib/itamae/resource/service.rb', line 27

def action_start(options)
  unless current.running
    run_specinfra(:start_service, attributes.name)
  end
end

#action_stop(options) ⇒ Object


33
34
35
36
37
# File 'lib/itamae/resource/service.rb', line 33

def action_stop(options)
  if current.running
    run_specinfra(:stop_service, attributes.name)
  end
end

#pre_actionObject


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/itamae/resource/service.rb', line 9

def pre_action
  case @current_action
  when :start, :restart
    attributes.running = true
  when :stop
    attributes.running = false
  when :enable
    attributes.enabled = true
  when :disable
    attributes.enabled = false
  end
end

#set_current_attributesObject


22
23
24
25
# File 'lib/itamae/resource/service.rb', line 22

def set_current_attributes
  current.running = run_specinfra(:check_service_is_running, attributes.name)
  current.enabled = run_specinfra(:check_service_is_enabled, attributes.name)
end