-
Notifications
You must be signed in to change notification settings - Fork 196
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
Autoreload with gunicorn? #50
Comments
Hi. Sorry for the delay, I also fling Django with gunicorn, so this would definitely be useful for me, too. I think the cleanest way to accomplish generic reloading would be to simply add a setting that gets executed as a shell command, this could be e.g. "sudo supervisorctl restart myapp_gunicorn" or "touch myapp.wsgi" when running under mod_wsgi. |
Hi all, one way to approach this is through signals. Currently rosetta trigger post_save signal and one could listen to this signal to reload gunicorn: Did not tried but I think this should work: from django.dispatch import receiver
from rosetta.signals import post_save
@receiver(post_save)
def restart_server(sender, **kwargs):
import os
os.system("kill -HUP `cat /tmp/myproject.pid`") I do like idea that command for reloading is read from settings as this would allow different settings for dev/prod environments. Here is similar approach to trigger django dev server reloading: from django.dispatch import receiver
from rosetta.signals import post_save
@receiver(post_save)
def restart_server(sender, **kwargs):
import os
os.system("sleep 1 && echo \"Rosetta reload\" && touch %s &" % __file__) Note: running this process in background and sleeping for one second should give current rosetta view to redirect properly. |
+1 Do you know guys when this will be fixed ? Is there any workaround ? Thx |
I'm curious as I'm unfamiliar with the internals, but is the reload/restart necessary? Would this snippet implemented as a post_save receiver (instead of middleware) accomplish the same? |
Not sure what is the status for this,
|
@chitak The problem with that is it will only work if your web application user has permission to use supervisorctl, which is not a particularly scalable or common setup, I think. If you want a more robust solution, try with the snippet I posted above. |
Any working workaround? |
Is there any chance to reload translation with gunicorn?
Something similar to ROSETTA_WSGI_AUTO_RELOAD and ROSETTA_UWSGI_AUTO_RELOAD.
The text was updated successfully, but these errors were encountered: