-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add brew bundle exec --services
#19552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good so far! What happens if there's an existing service already running, will this automatically stop it? If not: that seems desirable.
Not currently. Not sure how such CLI should look. |
d300326
to
486ec7d
Compare
Don't feel strongly about the API. I agree with not removing the service if possible but, if it's not, it feels more sensible to remove it. I think for |
Rebased on #19579 to avoid conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Bo98! Not sure exactly how but it feels like the e.g. service_change_state!
logic in bundle/brew_installer.rb
and/or bundle/brew_services.rb
should be integrated here. Not sure I understand why/when you'd use bundle/brew_services.rb
vs. bundle/services
?
The base branch was changed.
It intentionally behaves a little differently but indeed this should at least be following the versioned env path so I've made it now do so.
I've done this now
I've folded the latter into |
1f5e3d9
to
f0f9bcf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Might be nice to extract the brew bundle services
commands into another PR; think they require a bit more thought/discussion and the rest seems almost ready to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Bo98, great work! Merging as-is but would love some of the missing test coverage to come in a follow-up PR.
exit_code = 0 | ||
run_services(@dsl.entries) do | ||
Kernel.system(*args) | ||
exit_code = $CHILD_STATUS.exitstatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love a follow-up PR with some test coverage here.
).void | ||
} | ||
private_class_method def self.map_service_info(entries, &_block) | ||
entries_formulae = entries.filter_map do |entry| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love a follow-up PR with some test coverage here.
|
||
sig { params(entries: T::Array[Homebrew::Bundle::Dsl::Entry], _block: T.nilable(T.proc.void)).void } | ||
private_class_method def self.run_services(entries, &_block) | ||
services_to_restart = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love a follow-up PR with some test coverage here.
|
||
sig { params(entries: T::Array[Homebrew::Bundle::Dsl::Entry]).void } | ||
private_class_method def self.stop_services(entries) | ||
map_service_info(entries) do |info, _, _| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love a follow-up PR with some test coverage here.
A nice shortcut to quickly start and stop all formulae with services in your Brewfile. This makes it nicer if you have e.g. differing database versions (which often still share the same port) between projects.