Class: AutomateIt::ServiceManager::SYSV
- Inherits:
-
BaseDriver
- Object
- Common
- Plugin::Base
- Plugin::Driver
- BaseDriver
- AutomateIt::ServiceManager::SYSV
- Defined in:
- lib/automateit/service_manager/sysv.rb
Overview
ServiceManager::SYSV
The SYSV driver implements the ServiceManager methods for #running?, #start and #stop on Unix-like platforms that use the System V init process using a /etc/init.d
directory.
It also implements a basic #enabled? method that’s very fast but may not work correctly on all SysV platforms. This method should be overridden by more specific drivers when reasonable.
It does not implement the #enable and #disable methods because these are not standardized and must be implemented using platform-specific drivers, e.g., Chkconfig on RedHat-like platforms.
Constant Summary collapse
- ETC_INITD =
"/etc/init.d"
Constants inherited from Plugin::Driver
Plugin::Driver::BASE_DRIVER_NAME
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::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#enabled?(service) ⇒ Boolean
See ServiceManager#enabled?.
-
#restart(service, opts = {}) ⇒ Object
See ServiceManager#restart.
-
#running?(service, opts = {}) ⇒ Boolean
See ServiceManager#running?.
-
#start(service, opts = {}) ⇒ Object
See ServiceManager#start.
-
#started?(service, opts = {}) ⇒ Boolean
See ServiceManager#started?.
-
#stop(service, opts = {}) ⇒ Object
See ServiceManager#stop.
-
#stopped?(service, opts = {}) ⇒ Boolean
See ServiceManager#stopped?.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
-
#tell(service, action, opts = {}) ⇒ Object
See ServiceManager#tell.
Methods inherited from BaseDriver
#start_and_enable, #start_or_restart
Methods inherited from Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #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
#enabled?(service) ⇒ Boolean
See ServiceManager#enabled?
135 136 137 |
# File 'lib/automateit/service_manager/sysv.rb', line 135 def enabled?(service) return ! Dir["/etc/rc*.d/*"].grep(/\/S\d{2}#{service}$/).empty? end |
#restart(service, opts = {}) ⇒ Object
See ServiceManager#restart
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/automateit/service_manager/sysv.rb', line 120 def restart(service, opts={}) if started?(service, :wait => opts[:pause]) # We're certain that service is started stop_opts = opts.clone stop_opts[:force] = true # Don't check again stop(service, stop_opts) end # We're certain that service is stopped start_opts = opts.clone start_opts[:force] = true # Don't check again return start(service, start_opts) end |
#running?(service, opts = {}) ⇒ Boolean
See ServiceManager#running?
50 51 52 |
# File 'lib/automateit/service_manager/sysv.rb', line 50 def running?(service, opts={}) return started?(service, opts) end |
#start(service, opts = {}) ⇒ Object
See ServiceManager#start
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/automateit/service_manager/sysv.rb', line 96 def start(service, opts={}) if not opts[:force] and started?(service, :wait => opts[:wait]) # Already started return false else # Needs starting or forced tell(service, :start, opts) return true end end |
#started?(service, opts = {}) ⇒ Boolean
See ServiceManager#started?
86 87 88 |
# File 'lib/automateit/service_manager/sysv.rb', line 86 def started?(service, opts={}) return _started_and_stopped_helper(:started?, service, opts) end |
#stop(service, opts = {}) ⇒ Object
See ServiceManager#stop
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/automateit/service_manager/sysv.rb', line 108 def stop(service, opts={}) if not opts[:force] and stopped?(service, :wait => opts[:wait]) # Already stopped return false else # Needs stopping or forced tell(service, :stop, opts) return true end end |
#stopped?(service, opts = {}) ⇒ Boolean
See ServiceManager#stopped?
91 92 93 |
# File 'lib/automateit/service_manager/sysv.rb', line 91 def stopped?(service, opts={}) return ! _started_and_stopped_helper(:stopped?, service, opts) end |
#suitability(method, *args) ⇒ Object
:nodoc:
19 20 21 22 |
# File 'lib/automateit/service_manager/sysv.rb', line 19 def suitability(method, *args) # :nodoc: return 0 if %w(enabled? enable disable).include?(method.to_s) return available? ? 1 : 0 end |