Django and SaaS + Ztask for background tasks

て烟熏妆下的殇ゞ 提交于 2019-12-24 10:57:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!