Skip to content
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

Improve behavior of --all #625

Merged
merged 2 commits into from
Feb 20, 2024
Merged

Improve behavior of --all #625

merged 2 commits into from
Feb 20, 2024

Conversation

stefansundin
Copy link
Contributor

This changes how --all behaves. When stopping all services, it filters out the services that are already stopped, and vice versa when starting all services.

My motivation for this change is that I have dnscrypt-proxy installed which causes brew services stop --all to no longer work properly and stop halfway through.

$ brew services list
Name           Status  User   File
caddy          none           
dnscrypt-proxy none    root   
grafana        started stefan ~/Library/LaunchAgents/homebrew.mxcl.grafana.plist

$ brew services stop --all
Warning: Service `caddy` is not started.
Error: Service `dnscrypt-proxy` is started as `root`. Try:
  sudo brew services stop dnscrypt-proxy

$ brew services list
Name           Status  User   File
caddy          none           
dnscrypt-proxy none    root   
grafana        started stefan ~/Library/LaunchAgents/homebrew.mxcl.grafana.plist

With my changes it works the way I want it to:

$ brew services list
Name           Status  User   File
caddy          none           
dnscrypt-proxy none    root   
grafana        started stefan ~/Library/LaunchAgents/homebrew.mxcl.grafana.plist

$ brew services stop --all
Stopping `grafana`... (might take a while)
==> Successfully stopped `grafana` (label: homebrew.mxcl.grafana)

$ brew services list
Name           Status User File
caddy          none        
dnscrypt-proxy none   root 
grafana        none        

You'll no longer see Warning: Service `X` is not started. warnings when using --all, which cleans up the output a lot.

If you have root services then brew services start --all no longer tries to start them. Perhaps a new switch should be included to allow this to be controlled, e.g. --include-root? In my opinion the default should exclude root services since I think it is the exception rather than the rule where you want to include them, right?

$ brew services start --all
==> Successfully started `caddy` (label: homebrew.mxcl.caddy)
==> Successfully started `grafana` (label: homebrew.mxcl.grafana)

The tests are still passing. Please let me know if you want me to make any changes. If you want me to add to the tests then please let me know. I don't want to spend time on tests unless the changes are desirable.

Thanks!

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, great work @stefansundin!

@MikeMcQuaid MikeMcQuaid merged commit 13d68f9 into Homebrew:master Feb 20, 2024
5 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants