Skip to content

Commit 0d6de64

Browse files
authored
Merge pull request #19706 from Homebrew/revert-19703-bundle-exec-simultaneous-services
Revert "bundle: handle simultaneous `exec --services` better"
2 parents 4c56360 + 94db0b2 commit 0d6de64

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

Library/Homebrew/bundle/commands/exec.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false)
179179
params(
180180
entries: T::Array[Homebrew::Bundle::Dsl::Entry],
181181
_block: T.proc.params(
182-
entry: Homebrew::Bundle::Dsl::Entry,
183182
info: T::Hash[String, T.anything],
184183
service_file: Pathname,
185184
conflicting_services: T::Array[T::Hash[String, T.anything]],
@@ -246,20 +245,15 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false)
246245

247246
raise "Failed to get service info for #{entry.name}" if info.nil?
248247

249-
yield entry, info, service_file, conflicting_services
248+
yield info, service_file, conflicting_services
250249
end
251250
end
252251

253252
sig { params(entries: T::Array[Homebrew::Bundle::Dsl::Entry], _block: T.nilable(T.proc.void)).void }
254253
private_class_method def self.run_services(entries, &_block)
255-
entries_to_stop = []
256254
services_to_restart = []
257255

258-
map_service_info(entries) do |entry, info, service_file, conflicting_services|
259-
# Don't restart if already running this version
260-
loaded_file = Pathname.new(info["loaded_file"].to_s)
261-
next if info["running"] && loaded_file&.file? && loaded_file&.realpath == service_file.realpath
262-
256+
map_service_info(entries) do |info, service_file, conflicting_services|
263257
if info["running"] && !Bundle::BrewServices.stop(info["name"], keep: true)
264258
opoo "Failed to stop #{info["name"]} service"
265259
end
@@ -275,8 +269,6 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false)
275269
unless Bundle::BrewServices.run(info["name"], file: service_file)
276270
opoo "Failed to start #{info["name"]} service"
277271
end
278-
279-
entries_to_stop << entry
280272
end
281273

282274
return unless block_given?
@@ -285,7 +277,7 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false)
285277
yield
286278
ensure
287279
# Do a full re-evaluation of services instead state has changed
288-
stop_services(entries_to_stop)
280+
stop_services(entries)
289281

290282
services_to_restart.each do |service|
291283
next if Bundle::BrewServices.run(service)
@@ -297,7 +289,7 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false)
297289

298290
sig { params(entries: T::Array[Homebrew::Bundle::Dsl::Entry]).void }
299291
private_class_method def self.stop_services(entries)
300-
map_service_info(entries) do |_, info, _, _|
292+
map_service_info(entries) do |info, _, _|
301293
next unless info["loaded"]
302294

303295
# Try avoid services not started by `brew bundle services`

Library/Homebrew/test/bundle/commands/exec_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@
185185
allow(pkgconf).to receive(:any_version_installed?).and_return(false)
186186

187187
allow_any_instance_of(Pathname).to receive(:file?).and_return(true)
188-
allow_any_instance_of(Pathname).to receive(:realpath) { |path| path }
189188

190189
allow(described_class).to receive(:exit!).and_return(nil)
191190
end

0 commit comments

Comments
 (0)