Comments (7)
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.
from django-rosetta.
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:
https://github.com/mbi/django-rosetta/blob/develop/rosetta/views.py#L149
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.
from django-rosetta.
+1 Do you know guys when this will be fixed ? Is there any workaround ? Thx
from django-rosetta.
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?
from django-rosetta.
Not sure what is the status for this,
because I am using supervisor+gunicorn, so I modify slightly this snippet, and it works. I define this in my signals.py
@receiver(post_save)
def restart_server(sender, **kwargs):
os.system('supervisorctl restart <myproject>')
from django-rosetta.
@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.
from django-rosetta.
Any working workaround?
from django-rosetta.
Related Issues (20)
- TemplateDoesNotExist at /rosetta/files/project HOT 2
- Why request some url `https://www.google.com/jsapi` HOT 2
- 'Last-Translator' is written as b'....' in pofile
- Plurals with context are rendered incorrectly HOT 6
- `re_path` is not available in django==4.0 anymore HOT 3
- request or news (I can look) save to database for docker HOT 5
- Why split `DJANGO_SETTINGS_MODULE` in function find_pos()? HOT 1
- Missing Azure Location setting HOT 1
- Export Django-rosetta translations HOT 1
- DeepL suggestions not working HOT 1
- Triple entries in local dev env on Mac HOT 8
- anyone can add chatgpt support? HOT 2
- DeepL translates variable names
- DeepL Pro support HOT 3
- Updating docs to get ROSETTA_LANGUAGE_GROUPS=True working HOT 1
- REFLANG not working anymore? HOT 1
- Infinite Redirected Loop when Accessing Django Rosetta Page with users other than superuser HOT 1
- Chinese locale directory should be named 'zh_Hans' instead of 'zh_hans' HOT 2
- How to translate third-party apps?
- TypeError at../rosetta/files/project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rosetta.