gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

change --reload-extra-file option to get multiple files at once

Open firekim2 opened this issue 6 years ago • 20 comments

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

firekim2 avatar Aug 03 '18 02:08 firekim2

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.

tilgovi avatar Jan 22 '19 09:01 tilgovi

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.

tilgovi avatar Jan 22 '19 09:01 tilgovi

This is useful. Thanks!

trivedigaurav avatar Jan 28 '19 04:01 trivedigaurav

@firekim2 do you have time or interest to rebase this?

tilgovi avatar Jan 28 '19 05:01 tilgovi

@firekim2 do you have time or interest to rebase this?

Yes, I have. Let me try it.

firekim2 avatar Jan 28 '19 07:01 firekim2

@tilgovi rebased it

firekim2 avatar Jan 29 '19 08:01 firekim2

@firekim2 thanks! there i still one last question to answer but otherise the change is OK for me :)

benoitc avatar Jan 29 '19 08:01 benoitc

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

franekmagiera avatar Jan 24 '21 22:01 franekmagiera

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 ?

jgod avatar Apr 29 '21 20:04 jgod

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.

OrionReed avatar Mar 16 '22 02:03 OrionReed

Any updates on this?

nvnieuwk avatar Aug 02 '22 07:08 nvnieuwk

Please merge!

foobarbecue avatar Jan 15 '23 17:01 foobarbecue

It's necessary when we pass a directory that is applied recursively

manolomono avatar Jul 25 '23 10:07 manolomono

Anything I can do for merging this? And Sorry guys somehow alerts went into spam, and I only used GIthub Enterprise for a while!

firekim2 avatar Jul 28 '23 01:07 firekim2

Anything specifically holding this up? Would love to see this functionality merged

wrabit avatar Sep 10 '23 08:09 wrabit

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)

ShlomoCode avatar Dec 19 '23 10:12 ShlomoCode

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!

tilgovi avatar Dec 27 '23 23:12 tilgovi

Still waiting for this!

richpin avatar Mar 16 '24 06:03 richpin

The documentation can cause confusion about the theme while doing reference of reload_extra_files (on plural) for the singular parameter --reload-extra-file.

mpoletto avatar Mar 26 '24 18:03 mpoletto