Module: Utils::Service
- Defined in:
- utils/service.rb
Overview
Helpers for brew services
related code.
Class Method Summary collapse
-
.installed?(formula) ⇒ Boolean
Check if a service file is installed in the expected location.
-
.launchctl ⇒ Pathname?
Path to launchctl binary.
-
.launchctl? ⇒ Boolean
-
.running?(formula) ⇒ Boolean
Check if a service is running for a specified formula.
-
.systemctl ⇒ Pathname?
Path to systemctl binary.
-
.systemctl? ⇒ Boolean
Class Method Details
.installed?(formula) ⇒ Boolean
Check if a service file is installed in the expected location.
19 20 21 22 |
# File 'utils/service.rb', line 19 def self.installed?(formula) (launchctl? && formula.launchd_service_path.exist?) || (systemctl? && formula.systemd_service_path.exist?) end |
.launchctl ⇒ Pathname?
Path to launchctl binary.
26 27 28 29 30 |
# File 'utils/service.rb', line 26 def self.launchctl return @launchctl if defined? @launchctl @launchctl = which("launchctl") end |
.launchctl? ⇒ Boolean
41 42 43 |
# File 'utils/service.rb', line 41 def self.launchctl? !launchctl.nil? end |
.running?(formula) ⇒ Boolean
Check if a service is running for a specified formula.
9 10 11 12 13 14 15 |
# File 'utils/service.rb', line 9 def self.running?(formula) if launchctl? quiet_system(launchctl, "list", formula.plist_name) elsif systemctl? quiet_system(systemctl, "is-active", "--quiet", formula.service_name) end end |
.systemctl ⇒ Pathname?
Path to systemctl binary.
34 35 36 37 38 |
# File 'utils/service.rb', line 34 def self.systemctl return @systemctl if defined? @systemctl @systemctl = which("systemctl") end |
.systemctl? ⇒ Boolean
46 47 48 |
# File 'utils/service.rb', line 46 def self.systemctl? !systemctl.nil? end |