gunicorn
gunicorn copied to clipboard
change --reload-extra-file option to get multiple files at once
If I want to reload when templates changes, I should do like this right now: --reload-extra-file path/to/templates/file1 --reload-extra-file path/to/templates/file2 ...... add every file by file. I changed config.py to get files like: --reload-extra-file path/to/templates/* or --reload-extra-file path/to/templates/file1 path/to/templates/file2
I like this PR. I'm sorry I missed it before. I want to be sure it works correctly and haven't had a chance to test. My argparse knowledge is weak, but I've been reading the docs lately. If it works correctly, I support it.
The other thing I would check is that everything works correctly when this is the last flag. In other words, I would hope that it does not eat the required Python app module argument.
gunicorn --reload-extrafile file1 file2 app
should still work.
This is useful. Thanks!
@firekim2 do you have time or interest to rebase this?
@firekim2 do you have time or interest to rebase this?
Yes, I have. Let me try it.
@tilgovi rebased it
@firekim2 thanks! there i still one last question to answer but otherise the change is OK for me :)
Hi, stumbled upon this PR while trying to figure out a solution to #1643.
As for your question regarding the default value - I tested ""
and []
and they both work as expected. This is because the Setting
class in its set
method assigns the value that is returned from the validator
function - and the validator returns []
if the passed value is falsy - both ""
and []
are, so there is no error.
Argparse by default treats all arguments as strings so having ""
as default makes sense in my opinion. On the other hand, having []
does not rely on the validator doing the checking and substitution.
This also solves #1643 because argparse.ArgumentParser
's parse_args
methods resolves wildcards such as *json
.
@tilgovi @firekim2
It's been sitting around for a couple years. What does this need to go forward? Just a review from @benoitc @tilgovi or waiting on action from @firekim2 ?
Is there a blocker for this PR? Would really love to have this, or alternatively some kind of workaround as this covers quite a common case.
Any updates on this?
Please merge!
It's necessary when we pass a directory that is applied recursively
Anything I can do for merging this? And Sorry guys somehow alerts went into spam, and I only used GIthub Enterprise for a while!
Anything specifically holding this up? Would love to see this functionality merged
In the meantime, you can use a little bash script:
gunicorn app.wsgi --reload $(find templates -type f -name '*.html' -exec echo --reload-extra-file {} \;)
It tracks changes in every html file in the templates folder (or its subfolder)
I've pushed a version of this to #3124, preserving backwards compatibility and adding tests. @firekim2, I've kept you as the commit author and added myself as co-author. If you have a chance to review, that'd be great.
Thanks for your patience on this!
Still waiting for this!
The documentation can cause confusion about the theme while doing reference of reload_extra_files (on plural) for the singular parameter --reload-extra-file.