Class: Homebrew::Bundle::Brew::Services Private
- Inherits:
-
Homebrew::Bundle::Brew
- Object
- 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.
Class Method Summary collapse
- .reset! ⇒ void private
- .restart(name, file: nil, verbose: false) ⇒ Boolean private
- .run(name, file: nil, verbose: false) ⇒ Boolean private
- .service_file_for(formula, prefix) ⇒ Pathname? private
- .start(name, file: nil, verbose: false) ⇒ Boolean private
- .started?(name) ⇒ Boolean private
- .started_services ⇒ Array<String> private
- .started_services_without_daemon_manager ⇒ Array<String> private
- .stop(name, keep: false, verbose: false) ⇒ Object private
- .versioned_service_file(name) ⇒ Pathname? private
Instance Method Summary collapse
- #entry_to_formula(entry) ⇒ Homebrew::Bundle::Brew private
- #failure_reason(name, no_upgrade:) ⇒ String private
- #format_checkable(entries) ⇒ Array<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) ⇒ String? private
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_once, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_incompatible, pretty_install_status, pretty_installed, pretty_removed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning
Methods inherited from Homebrew::Bundle::Brew
#changed?, check_label, dump, dump_output, expected_link_status?, #find_actionable, find_formula, formula_aliases, formula_dump_link_status, formula_in_array?, formula_installed?, formula_installed_and_up_to_date?, formula_names_with_dependencies, formula_oldnames, formula_pinned?, formula_tap_changed?, formula_upgradable?, formulae, formulae_by_full_name, inherited, #initialize, install!, #install!, #install_change_state!, install_verb, installed_formulae, #link_change_state!, link_status_to_check, no_upgrade_with_args?, outdated_formulae, #pin_change_state!, #pin_needed?, pinned_formulae, #postinstall_change_state!, preinstall!, #preinstall!, #restart_service?, #restart_service_needed?, #service_change_state!, #start_service?, #start_service_needed?, type, upgradable_formulae
Methods inherited from PackageType
batch_installable?, check, check_label, #checkable_entries, dump, dump_output, dump_supported?, #exit_early_check, #find_actionable, #full_check, inherited, install!, install_batch!, install_supported?, install_verb, preinstall!, type
Constructor Details
This class inherits a constructor from Homebrew::Bundle::Brew
Class Method Details
.reset! ⇒ void
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.
This method returns an undefined value.
17 18 19 |
# File 'bundle/brew_services.rb', line 17 def reset! @started_services = T.let(nil, T.nilable(T::Array[String])) end |
.restart(name, file: nil, verbose: 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.
56 57 58 59 60 61 62 63 |
# File 'bundle/brew_services.rb', line 56 def restart(name, file: nil, verbose: false) args = ["services", "restart", name] args << "--file=#{file}" if file return false unless Bundle.brew(*args, verbose:) started_services << name true end |
.run(name, file: nil, verbose: 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.
46 47 48 49 50 51 52 53 |
# File 'bundle/brew_services.rb', line 46 def run(name, file: nil, verbose: false) args = ["services", "run", name] args << "--file=#{file}" if file return false unless Bundle.brew(*args, verbose:) started_services << name true end |
.service_file_for(formula, prefix) ⇒ Pathname?
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.
91 92 93 94 95 96 97 98 99 |
# File 'bundle/brew_services.rb', line 91 def service_file_for(formula, prefix) service_files = if Homebrew::Services::System.launchctl? formula.plist_names.map { |name| prefix/"#{name}.plist" } else formula.service_names.map { |name| prefix/"#{name}.service" } end service_files.find(&:file?) end |
.start(name, file: nil, verbose: 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.
36 37 38 39 40 41 42 43 |
# File 'bundle/brew_services.rb', line 36 def start(name, file: nil, verbose: false) args = ["services", "start", name] args << "--file=#{file}" if file return false 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.
67 68 69 |
# File 'bundle/brew_services.rb', line 67 def started?(name) started_services.include? name end |
.started_services ⇒ Array<String>
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.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'bundle/brew_services.rb', line 77 def started_services @started_services ||= if !Homebrew::Services::System.launchctl? && !Homebrew::Services::System.systemctl? started_services_without_daemon_manager else states_to_skip = %w[stopped none] services_list = JSON.parse(Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list", "--json")) services_list.filter_map do |hash| hash.fetch("name") if states_to_skip.exclude?(hash.fetch("status")) end end end |
.started_services_without_daemon_manager ⇒ Array<String>
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.
72 73 74 |
# File 'bundle/brew_services.rb', line 72 def started_services_without_daemon_manager odie Homebrew::Services::System::MISSING_DAEMON_MANAGER_EXCEPTION_MESSAGE 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.
24 25 26 27 28 29 30 31 32 33 |
# File 'bundle/brew_services.rb', line 24 def stop(name, keep: false, verbose: false) return true unless started?(name) args = ["services", "stop", name] args << "--keep" if keep return false unless Bundle.brew(*args, verbose:) started_services.delete(name) true end |
.versioned_service_file(name) ⇒ Pathname?
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.
102 103 104 105 106 107 108 109 110 111 |
# File 'bundle/brew_services.rb', line 102 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_for(formula, prefix) end |
Instance Method Details
#entry_to_formula(entry) ⇒ Homebrew::Bundle::Brew
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.
143 144 145 |
# File 'bundle/brew_services.rb', line 143 def entry_to_formula(entry) Homebrew::Bundle::Brew.new(entry.name, entry.) end |
#failure_reason(name, no_upgrade:) ⇒ String
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.
115 116 117 118 119 |
# File 'bundle/brew_services.rb', line 115 def failure_reason(name, no_upgrade:) _ = no_upgrade "Service #{name} needs to be started." end |
#format_checkable(entries) ⇒ Array<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.
161 162 163 |
# File 'bundle/brew_services.rb', line 161 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.
148 149 150 |
# File 'bundle/brew_services.rb', line 148 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.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'bundle/brew_services.rb', line 122 def installed_and_up_to_date?(formula, no_upgrade: false) _ = no_upgrade entry = T.cast(formula, Homebrew::Bundle::Dsl::Entry) return true unless formula_needs_to_start?(entry_to_formula(entry)) name = entry.name return true if self.class.started?(name) # `brew services list` returns base names, so fall back to the last # path component for tap-qualified entries (e.g., "user/tap/formula"). base_name = Utils.name_from_full_name(name) return true if base_name != name && self.class.started?(base_name) old_name = lookup_old_name(name) return true if old_name && self.class.started?(old_name) false end |
#lookup_old_name(service_name) ⇒ String?
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.
153 154 155 156 157 158 |
# File 'bundle/brew_services.rb', line 153 def lookup_old_name(service_name) @old_names ||= T.let(Homebrew::Bundle::Brew.formula_oldnames, T.nilable(T::Hash[String, String])) old_name = @old_names[service_name] old_name ||= @old_names[Utils.name_from_full_name(service_name)] old_name end |