Module: Utils::Service Private

Includes:
Kernel
Defined in:
utils/service.rb,
utils/service.rbi

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helpers for brew services related code.

Constant Summary

Constants included from Kernel

Kernel::IGNORE_INTERRUPTS_MUTEX

Class Method Summary collapse

Methods included from Kernel

#disk_usage_readable, #ensure_executable!, #ensure_formula_installed!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #number_readable, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #paths, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #quiet_system, #redact_secrets, #redirect_stdout, #require?, #safe_system, #tap_and_name_comparison, #truncate_text_to_approximate_size, #which, #which_all, #which_editor, #with_custom_locale, #with_env, #with_homebrew_path

Class Method Details

.installed?(formula) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Check if a service file is installed in the expected location.

Parameters:

Returns:

  • (Boolean)


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

.launchctlPathname?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Path to launchctl binary.

Returns:



26
27
28
29
30
31
# File 'utils/service.rb', line 26

def self.launchctl
  return @launchctl if defined? @launchctl
  return if ENV["HOMEBREW_TEST_GENERIC_OS"]

  @launchctl = which("launchctl")
end

.launchctl?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


43
44
45
# File 'utils/service.rb', line 43

def self.launchctl?
  !launchctl.nil?
end

.running?(formula) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Check if a service is running for a specified formula.

Parameters:

Returns:

  • (Boolean)


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

.systemctlPathname?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Path to systemctl binary.

Returns:



35
36
37
38
39
40
# File 'utils/service.rb', line 35

def self.systemctl
  return @systemctl if defined? @systemctl
  return if ENV["HOMEBREW_TEST_GENERIC_OS"]

  @systemctl = which("systemctl")
end

.systemctl?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


48
49
50
# File 'utils/service.rb', line 48

def self.systemctl?
  !systemctl.nil?
end