Class: LinuxAdmin::Service
- Inherits:
-
LinuxAdmin
- Object
- LinuxAdmin
- LinuxAdmin::Service
- Defined in:
- lib/linux_admin/service.rb
Constant Summary
Constants inherited from LinuxAdmin
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize(id) ⇒ Service
constructor
A new instance of Service.
- #restart ⇒ Object
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Common
Constructor Details
#initialize(id) ⇒ Service
Returns a new instance of Service.
14 15 16 |
# File 'lib/linux_admin/service.rb', line 14 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/linux_admin/service.rb', line 8 def id @id end |
Instance Method Details
#disable ⇒ Object
29 30 31 32 33 |
# File 'lib/linux_admin/service.rb', line 29 def disable run!(cmd(:chkconfig), :params => { nil => [id, "off"] }) self end |
#enable ⇒ Object
23 24 25 26 27 |
# File 'lib/linux_admin/service.rb', line 23 def enable run!(cmd(:chkconfig), :params => { nil => [id, "on"] }) self end |
#restart ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/linux_admin/service.rb', line 47 def restart status = run(cmd(:service), :params => { nil => [id, "restart"] }).exit_status # attempt to manually stop/start if restart fails if status != 0 self.stop self.start end self end |
#running? ⇒ Boolean
18 19 20 21 |
# File 'lib/linux_admin/service.rb', line 18 def running? run(cmd(:service), :params => { nil => [id, "status"] }).exit_status == 0 end |
#start ⇒ Object
35 36 37 38 39 |
# File 'lib/linux_admin/service.rb', line 35 def start run!(cmd(:service), :params => { nil => [id, "start"] }) self end |
#stop ⇒ Object
41 42 43 44 45 |
# File 'lib/linux_admin/service.rb', line 41 def stop run!(cmd(:service), :params => { nil => [id, "stop"] }) self end |