Class: Homebrew::Bundle::Brew::Services Private
- Inherits:
-
Homebrew::Bundle::Brew
- Object
- Checker::Base
- PackageType
- Homebrew::Bundle::Brew
- Homebrew::Bundle::Brew::Services
- Extended by:
- Utils::Output::Mixin
- Defined in:
- bundle/brew_services.rb
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Constant Summary
Constants inherited from Homebrew::Bundle::Brew
PACKAGE_TYPE, PACKAGE_TYPE_NAME
Class Method Summary collapse
- .reset! ⇒ Object private
- .restart(name, file: nil, verbose: false) ⇒ Object private
- .run(name, file: nil, verbose: false) ⇒ Object private
- .start(name, file: nil, verbose: false) ⇒ Object private
- .started?(name) ⇒ Boolean private
- .started_services ⇒ Object private
- .stop(name, keep: false, verbose: false) ⇒ Object private
- .versioned_service_file(name) ⇒ Object private
Instance Method Summary collapse
- #entry_to_formula(entry) ⇒ Object private
- #failure_reason(name, no_upgrade:) ⇒ Object private
- #format_checkable(entries) ⇒ Object private
- #formula_needs_to_start?(formula) ⇒ Boolean private
- #installed_and_up_to_date?(formula, no_upgrade: false) ⇒ Boolean private
- #lookup_old_name(service_name) ⇒ Object private
Methods included from Utils::Output::Mixin
odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, pretty_deprecated, pretty_disabled, pretty_duration, pretty_installed, pretty_outdated, pretty_uninstalled
Methods inherited from Homebrew::Bundle::Brew
#changed?, dump, dump_output, fetchable_name, formula_aliases, formula_in_array?, formula_installed?, formula_installed_and_up_to_date?, formula_oldnames, formula_upgradable?, formulae, formulae_by_full_name, formulae_by_name, #initialize, install!, #install!, #install_change_state!, install_verb, installed_formulae, #link_change_state!, no_upgrade_with_args?, outdated_formulae, pinned_formulae, #postinstall_change_state!, preinstall!, #preinstall!, #restart_service?, #restart_service_needed?, #service_change_state!, #start_service?, #start_service_needed?, upgradable_formulae
Methods inherited from PackageType
check, check_supported?, dump, dump_output, dump_supported?, fetchable_name, inherited, install_supported?, install_verb, type
Methods inherited from Checker::Base
#checkable_entries, #exit_early_check, #find_actionable, #full_check
Constructor Details
This class inherits a constructor from Homebrew::Bundle::Brew
Class Method Details
.reset! ⇒ Object
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.
15 16 17 |
# File 'bundle/brew_services.rb', line 15 def reset! @started_services = nil end |
.restart(name, file: nil, verbose: false) ⇒ Object
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.
48 49 50 51 52 53 54 55 |
# File 'bundle/brew_services.rb', line 48 def restart(name, file: nil, verbose: false) args = ["services", "restart", name] args << "--file=#{file}" if file return unless Bundle.brew(*args, verbose:) started_services << name true end |
.run(name, file: nil, verbose: false) ⇒ Object
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.
39 40 41 42 43 44 45 46 |
# File 'bundle/brew_services.rb', line 39 def run(name, file: nil, verbose: false) args = ["services", "run", name] args << "--file=#{file}" if file return unless Bundle.brew(*args, verbose:) started_services << name true end |
.start(name, file: nil, verbose: false) ⇒ Object
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.
30 31 32 33 34 35 36 37 |
# File 'bundle/brew_services.rb', line 30 def start(name, file: nil, verbose: false) args = ["services", "start", name] args << "--file=#{file}" if file return unless Bundle.brew(*args, verbose:) started_services << name true end |
.started?(name) ⇒ 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.
57 58 59 |
# File 'bundle/brew_services.rb', line 57 def started?(name) started_services.include? name end |
.started_services ⇒ Object
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.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'bundle/brew_services.rb', line 61 def started_services @started_services ||= begin if !Homebrew::Services::System.launchctl? && !Homebrew::Services::System.systemctl? odie Homebrew::Services::System::MISSING_DAEMON_MANAGER_EXCEPTION_MESSAGE end states_to_skip = %w[stopped none] Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list").lines.filter_map do |line| name, state, _plist = line.split(/\s+/) next if states_to_skip.include? state name end end end |
.stop(name, keep: false, verbose: false) ⇒ Object
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.
19 20 21 22 23 24 25 26 27 28 |
# File 'bundle/brew_services.rb', line 19 def stop(name, keep: false, verbose: false) return true unless started?(name) args = ["services", "stop", name] args << "--keep" if keep return unless Bundle.brew(*args, verbose:) started_services.delete(name) true end |
.versioned_service_file(name) ⇒ Object
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.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'bundle/brew_services.rb', line 76 def versioned_service_file(name) env_version = Bundle.formula_versions_from_env(name) return if env_version.nil? formula = Formula[name] prefix = formula.rack/env_version return unless prefix.directory? service_file = if Homebrew::Services::System.launchctl? prefix/"#{formula.plist_name}.plist" else prefix/"#{formula.service_name}.service" end service_file if service_file.file? end |
Instance Method Details
#entry_to_formula(entry) ⇒ Object
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.
112 113 114 |
# File 'bundle/brew_services.rb', line 112 def entry_to_formula(entry) Homebrew::Bundle::Brew.new(entry.name, entry.) end |
#failure_reason(name, no_upgrade:) ⇒ Object
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.
94 95 96 97 98 |
# File 'bundle/brew_services.rb', line 94 def failure_reason(name, no_upgrade:) _ = no_upgrade "Service #{name} needs to be started." end |
#format_checkable(entries) ⇒ Object
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.
127 128 129 |
# File 'bundle/brew_services.rb', line 127 def format_checkable(entries) checkable_entries(entries) end |
#formula_needs_to_start?(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.
116 117 118 |
# File 'bundle/brew_services.rb', line 116 def formula_needs_to_start?(formula) formula.start_service? || formula.restart_service? end |
#installed_and_up_to_date?(formula, no_upgrade: false) ⇒ 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.
100 101 102 103 104 105 106 107 108 109 110 |
# File 'bundle/brew_services.rb', line 100 def installed_and_up_to_date?(formula, no_upgrade: false) _ = no_upgrade return true unless formula_needs_to_start?(entry_to_formula(formula)) return true if self.class.started?(formula.name) old_name = lookup_old_name(formula.name) return true if old_name && self.class.started?(old_name) false end |
#lookup_old_name(service_name) ⇒ Object
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.
120 121 122 123 124 125 |
# File 'bundle/brew_services.rb', line 120 def lookup_old_name(service_name) @old_names ||= Homebrew::Bundle::Brew.formula_oldnames old_name = @old_names[service_name] old_name ||= @old_names[service_name.split("/").last] old_name end |