问题
I asked a question before on how to create a SaaS application using Django Django and SaaS. How to use separate database for each Django site?
Now when a user creates a new instance for himself I simply create a new settings.py file for him, and create an apache configuration for his subdomain. Now when a user tries to access his instance he can only see his own database, so we have total separation of data.
Now there is a problem when trying to do background processes while having these separate databases. Background processes should be specific to each instance acting only on this instance data. ZTask daemon takes a settings file to start. The question is do I have to start a separate ztaskd process for each Django instance? or can I start ztaskd once for all instances?
回答1:
ztaskd
works within a context of particular Django instance, so you cannot share one ZTask daemon for multiple Django instances.
You should run ztaskd
for each Django instance with it's local settings. Basically start it using
python manage.py ztaskd --settings=clients.site_settings &
Remember to have non-conflicting ZTASKD_URL
for each instance. For local ztaskd
ZTASKD_URL = 'ipc:///tmp/%s_ztask.sock' % SITE_NAME
as suggested in an answer to your previous question is good idea.
来源:https://stackoverflow.com/questions/10429274/django-and-saas-ztask-for-background-tasks