Class: Hookit::Resource::Service
- Defined in:
- lib/hookit/resource/service.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(name) ⇒ Service
constructor
A new instance of Service.
- #run(action) ⇒ Object
Methods inherited from Base
#action, actions, #can_run?, default_action, #default_action, field, #not_if, #only_if
Constructor Details
#initialize(name) ⇒ Service
Returns a new instance of Service.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hookit/resource/service.rb', line 13 def initialize(name) service_name(name) unless service_name super # if init scheme is not provided, try to set reasonable defaults if not init case platform.name when 'smartos' init(:smf) when 'ubuntu' init(:upstart) when 'docker' init(:runit) end end end |
Instance Method Details
#run(action) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hookit/resource/service.rb', line 30 def run(action) case action when :enable enable! when :disable disable! when :start enable! when :stop disable! when :force_stop force_disable! when :restart restart! when :reload reload! end end |