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

Adds a --silent option to the CLI #2803

Merged
merged 3 commits into from Jan 19, 2022
Merged

Conversation

gottfrois
Copy link
Contributor

@gottfrois gottfrois commented Jan 18, 2022

Description

This PR adds a -s, --silent option which deactivate Puma messages displayed on the prompt.

Without the option:

$ bundle exec bin/puma test/rackup/hello.ru
Puma starting in single mode...
* Puma version: 5.5.2 (ruby 2.6.6-p146) ("Zawgyi")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 88245
* Listening on http://0.0.0.0:9292
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2022-01-18 16:38:07 +0100 ===
- Goodbye!

With the option:

$ bundle exec bin/puma --silent test/rackup/hello.ru
^C%

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

@MSP-Greg
Copy link
Member

@MSP-Greg MSP-Greg commented Jan 18, 2022

Do we really want to silence STDERR?

@gottfrois
Copy link
Contributor Author

@gottfrois gottfrois commented Jan 18, 2022

Good catch, might want to leave the stderr as it is

@MSP-Greg
Copy link
Member

@MSP-Greg MSP-Greg commented Jan 18, 2022

Using @events = Events.new NullIO.new, STDERR seems to work, as errors are written.

I think the test will always pass, as Puma::Events.null.class or any call to Puma::Events.new will have a class of Puma::Events.

Not sure about this, let's see what others think...

@nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Jan 18, 2022

Agree with Greg. Also, isn't this option usually called quiet?

@dentarg
Copy link
Member

@dentarg dentarg commented Jan 18, 2022

Puma has -q, --quiet, but it is used to silent the request logging (and it is on by default), from puma --help,

-q, --quiet                      Do not log requests internally (default true)

(we have -v, --log-requests to turn it on)

@gottfrois
Copy link
Contributor Author

@gottfrois gottfrois commented Jan 19, 2022

I've reverted the stderr not to be silent as suggested.

@nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Jan 19, 2022

Change looks super clean. Glad this wasn't too hard to implement.

@nateberkopec nateberkopec merged commit 3f3c2f6 into puma:master Jan 19, 2022
48 checks passed
@gottfrois gottfrois deleted the silent-opts branch Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants