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
Graceful reload (HUP) is broken #25
Comments
For me all this looks like Manager.run command implementation (https://github.com/klen/muffin/blob/develop/muffin/manage.py#L89) is not correct: it sets configuration onto gunicorn app, but that configuration will not persist; probably we should leverage Gunicorn's command-line arguments parser (https://github.com/benoitc/gunicorn/blob/master/gunicorn/app/base.py#L140) or rather pass our configuration as "defaults" in our load_default_config implementation (https://github.com/klen/muffin/blob/develop/muffin/worker.py#L38): store these values in some object within a GunicornApp and load them with separate method which will be called both by Manager.run() and load_default_config(): from muffin.worker import GunicornApp
base_cfg = dict(
bind = bind,
daemon = daemon,
<...>
)
gapp = GunicornApp(
usage='...',
base_config=base_cfg,
config=self.app.cfg.CONFIG,
)
gapp.run() and in load_default_config: super().load_default_config()
del self.cfg.settings['paste']
del self.cfg.settings['django_settings']
# now load our defaults
for k,v in self._base_config.items():
self.cfg.set(k, v)
self.cfg.settings['worker_class'].default = ... |
@MarSoft Thanks for the report I will look at it next week. Maybe @matrixise could also help there. |
@MarSoft a quick glance at the code let me think you're right. On HUP Gunicorn tries to reload every parameters from the conf by reloading it. But I will check. |
This issue is also related to #19: Muffin's application class is loaded during initialization of Manager, so reloading will not work properly anyway. I think it can be fixed by rewriting manage.py so that |
Doesn't actual for version > 0.45 |
Seems that graceful reloading on SIGHUP (which is the feature of Gunicorn) is broken in Muffin.
For now I found two problems:
app
and is launched asmuffin <module> run
. It then loadsapp
object from the module and sets that object to Gunicorn's app. Also it passes<module>
to Gunicorn as app name.Now, when Gunicorn tries to reload on HUP, it parses app name and tries to separate it by ':' to determine app variable name; it then cannot find a ':' and defaults variable name to
application
, instead ofapp
used by muffin: https://github.com/benoitc/gunicorn/blob/master/gunicorn/util.py#L352My current workaround for it is as follows:
app = Muffin(...)
application = app
Line with
[,<,g,u,n,i,...
is result of a bug in Gunicorn - see benoitc/gunicorn#1181; actually it is ahttp://127.0.0.1:8000
, which takes its origin from https://github.com/benoitc/gunicorn/blob/master/gunicorn/config.py#L498For now I yet have no ideas on how to fix these problems.
The text was updated successfully, but these errors were encountered: