Class: AutomateIt::ServiceManager
- Inherits:
-
Plugin::Manager
- Object
- Common
- Plugin::Base
- Plugin::Manager
- AutomateIt::ServiceManager
- Defined in:
- lib/automateit/service_manager.rb
Overview
ServiceManager
ServiceManager provides a way of managing services, such starting and stopping Unix daemons.
Defined Under Namespace
Classes: BaseDriver, Chkconfig, RC_Update, SYSV, UpdateRCD
Constant Summary
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from Plugin::Manager
Attributes inherited from Common
Instance Method Summary collapse
-
#disable(service, opts = {}) ⇒ Object
Don’t make this
service
start when the computer is rebooted, but only if it’s already enabled. -
#enable(service, opts = {}) ⇒ Object
Make this
service
start when the computer is rebooted, but only if it’s not already enabled. -
#enabled?(service) ⇒ Boolean
Will this
service
start when the computer is rebooted?. -
#restart(service, opts = {}) ⇒ Object
Restart this
service
if it’s running, or start it if it’s stopped. -
#running?(service, opts = {}) ⇒ Boolean
Alias for #started?.
-
#start(service, opts = {}) ⇒ Object
Start this
service
if it’s not running. -
#start_and_enable(service, opts = {}) ⇒ Object
Start and enable the service using #start and #enable.
-
#start_or_restart(service, is_restart, opts = {}) ⇒ Object
If
is_restart
, #restart the service, otherwise #start it. -
#started?(service, opts = {}) ⇒ Boolean
Is this
service
started?. -
#stop(service, opts = {}) ⇒ Object
Stop this
service
if it’s running. -
#stopped?(service, opts = {}) ⇒ Boolean
Is this
service
stopped?. -
#tell(service, action, opts = {}) ⇒ Object
Tell the
service
to take a specificaction
, e.g., “condrestart”.
Methods inherited from Plugin::Manager
#[], abstract_manager, alias_methods, #available?, #default, #default=, #dispatch, #dispatch_safely, #dispatch_safely_to, #dispatch_to, driver_classes, #driver_for, #driver_suitability_levels_for, inherited, #instantiate_drivers, #setup
Methods inherited from Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#disable(service, opts = {}) ⇒ Object
Don’t make this service
start when the computer is rebooted, but only if it’s already enabled.
70 |
# File 'lib/automateit/service_manager.rb', line 70 def disable(service, opts={}) dispatch(service, opts) end |
#enable(service, opts = {}) ⇒ Object
Make this service
start when the computer is rebooted, but only if it’s not already enabled.
66 |
# File 'lib/automateit/service_manager.rb', line 66 def enable(service, opts={}) dispatch(service, opts) end |
#enabled?(service) ⇒ Boolean
Will this service
start when the computer is rebooted?
62 |
# File 'lib/automateit/service_manager.rb', line 62 def enabled?(service) dispatch(service) end |
#restart(service, opts = {}) ⇒ Object
Restart this service
if it’s running, or start it if it’s stopped.
Options:
-
:wait – Maxmimum seconds to wait for service to STOP.
-
:pause – Maximum seconds to wait for service to START before stopping it. Only set this if you just started the service and then decided to restart it.
46 |
# File 'lib/automateit/service_manager.rb', line 46 def restart(service, opts={}) dispatch(service, opts) end |
#running?(service, opts = {}) ⇒ Boolean
Alias for #started?
23 |
# File 'lib/automateit/service_manager.rb', line 23 def running?(service, opts={}) dispatch_to(:started?, service, opts) end |
#start(service, opts = {}) ⇒ Object
Start this service
if it’s not running.
Options:
-
:wait – Same as :wait option for #started?
-
:force – Start service without checking if it’s running.
30 |
# File 'lib/automateit/service_manager.rb', line 30 def start(service, opts={}) dispatch(service, opts) end |
#start_and_enable(service, opts = {}) ⇒ Object
Start and enable the service using #start and #enable.
56 |
# File 'lib/automateit/service_manager.rb', line 56 def start_and_enable(service, opts={}) dispatch(service, opts) end |
#start_or_restart(service, is_restart, opts = {}) ⇒ Object
If is_restart
, #restart the service, otherwise #start it.
Example:
modified = edit "/etc/myapp.conf" {#...}
service_manager.start_or_restart("myapp", modified)
53 |
# File 'lib/automateit/service_manager.rb', line 53 def start_or_restart(service, is_restart, opts={}) dispatch(service, is_restart, opts) end |
#started?(service, opts = {}) ⇒ Boolean
Is this service
started?
Options:
-
:wait – Maximum number of seconds to wait until service starts. Useful when a service accepts a #start and returns immediately before the service has finished starting.
12 |
# File 'lib/automateit/service_manager.rb', line 12 def started?(service, opts={}) dispatch(service, opts) end |
#stop(service, opts = {}) ⇒ Object
Stop this service
if it’s running.
Options:
-
:wait – Same as :wait option for #stopped?
-
:force – Stop service without checking if it’s running.
37 |
# File 'lib/automateit/service_manager.rb', line 37 def stop(service, opts={}) dispatch(service, opts) end |
#stopped?(service, opts = {}) ⇒ Boolean
Is this service
stopped?
Options:
-
:wait – Maximum number of seconds to wait until service stops. Useful when a service accepts a #stop and returns immediately while the service continues running for a few seconds.
20 |
# File 'lib/automateit/service_manager.rb', line 20 def stopped?(service, opts={}) dispatch(service, opts) end |
#tell(service, action, opts = {}) ⇒ Object
Tell the service
to take a specific action
, e.g., “condrestart”.
59 |
# File 'lib/automateit/service_manager.rb', line 59 def tell(service, action, opts={}) dispatch(service, action, opts={}) end |