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
Restructure of CLI and application state #2295
Conversation
@Tronic We discussed making To compensate for that, I buried some of the noise with |
Could you make the mode line display: Also, the graphic will look bad on MacOS but I guess there is not much to be done about that. |
And actually, replace the host and port lines with URLs and avoid the separate goin' fast message we have been printing. Or a URL, for now... Or an UNIX socket. I think at some point we have to allow serving multiple IPs (like IPv4 and IPv6) from the same instance, meaning that there could be more than one URL. |
@Tronic I was planning on changing the host/port like like you suggested because I knew I needed to support unix socket alternative. I agree about the multiple IPs, but that is a much larger PR since we really should think about how to have 1+ Sanic instances to 1+ bindings. I incorporated your idea about bringing workers into the
I plan to play around with it on Mac and Windows. If it looks terrible, then we can fallback to text based. |
A couple more additions:
And the non-tty version:
|
Great! Now just drop one of the Goin' fast so that it is not needlessly repeated :) I did not yet look at the verbosity changes but maybe still make (some of) these messages INFO rather than DEBUG? |
The "goin' fast" in the
I am assuming you mean the non-TTY version. I am not sure about how best to handle this. On the one hand you are likely in a prod container. On the other, it is still nice to have the output in your logs. Maybe I'll leave these as INFO for now and we can think about that at a later point. For now, the verbosity changes I made only touch the signals. But there probable are some other points we could use it. |
FYI - I confirmed on my Windows laptop that the color looks correct using:
I will test on OSX later today |
Also, seem to be missing tests for the warning when setting |
Code Climate has analyzed commit fc40d78 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 86.3% (86% is the threshold). This pull request will bring the total coverage in the repository to 86.6% (-0.1% change). View more on Code Climate. |
* Initial work on restructure of application state * Updated MOTD with more flexible input and add basic version * Remove unnecessary type ignores * Add wrapping and smarter output per process type * Add support for ASGI MOTD * Add Windows color support ernable * Refactor __main__ into submodule * Renest arguments * Passing unit tests * Passing unit tests * Typing * Fix num worker test * Add context to assert failure * Add some type annotations * Some linting * Line aware searching in test * Test abstractions * Fix some flappy tests * Bump up timeout on CLI tests * Change test for no access logs on gunicornworker * Add some basic test converage * Some new tests, and disallow workers and fast on app.run
Closes #2169
Replaces #2237
Purpose
This PR started out as a way to add some additional running defaults via the CLI. It has grown in scope a little and is taking on some refactoring of the
Sanic
class (still much more is needed).The big change (although we strive for backwards compat here, so please LMK if you see anything that is breaking) is to move some properties from the
Sanic
instance to a newApplicationState
instance. After v21.12, there is a lot more refactoring to be done.Implementation
--debug
to deprecate auto-reloading and remove in 22.3Additions
The new features are:
--fast
: default to the maximum allowed workers--verbosity
: allows us to hide some logging noiseCleanup
There is also a bit of refactoring of
__main__
to move it into a module. The single function was getting a bit messy to maintain. While I did not touch the bulk of the logic (saved for another time), it does make it a little easier to handle the addition of arguments. And, a side benefit is that they are grouped together a little more nicely.