gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

`reload_extra_files` should accept wildcards

Open ocervell opened this issue 8 years ago • 5 comments

Hi,

My app structure is such that each view in my app has it's own config.json located at ui/<view_name>/config.json.

I would love to reload on modification for each of those JSON files.

Currently, I'm doing, for each view:

reload_extra_file = [
  'ui/<view_1>/config.json',
  'ui/<view_2>/config.json',
  'ui/<view_3>/config.json,
  ...
]

but this is a little cumbersome, since I have to add a new line everytime I add a view to my app (and I tend to forget about it).

We should support wildcards for this kind of use case, something like:

reload_extra_file = ['*.json', '*.js', '*.py', '*.yaml']

@benoitc Is that something you would consider implementing ? I can maybe help with this and create a PR if you let me know where this needs to be changed in the current code.

ocervell avatar Nov 14 '17 16:11 ocervell

@ocervell You could simply solve this by using glob to populate that list.

from glob import glob
reload_extra_file = glob('*.json')

halfdan avatar Jun 17 '19 22:06 halfdan

Since I don't see a compelling reason not to support this, I'd review a PR.

tilgovi avatar Jun 17 '19 23:06 tilgovi

as @tilgovi said, any PR is welcome :)

benoitc avatar Nov 22 '19 21:11 benoitc

What's the status on this? This would be an enormously useful feature. Is it implemented and I'm misunderstanding?

changeling avatar Oct 29 '20 18:10 changeling

I believe the potential unexpected and unintended glob expansion (or confusing error message on lack thereof, in the nullglob case) in an option that is not clearly containing "-glob" (or "-regex", if that was the accepted syntax) paired with the relative ease of alternate solutions is a compelling reason to not implement this. At least not as a modification to the default behaviour of the existing option. And even where gunicorn could do what the invoking shell or python config also offer, that is often still worse than letting a specific tool that knows about exception handle it, such as git ls-files "**.py".

Maybe after future argparse refactoring, a --glob (separate option, or modifier) could be introduced.

pajod avatar May 22 '24 06:05 pajod