Django和SaaS + Ztask用于后台任务 [英] Django and SaaS + Ztask for backgroud tasks

查看:616
本文介绍了Django和SaaS + Ztask用于后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前曾问过如何使用Django创建SaaS应用程序
Django和SaaS。如何为每个Django网站使用单独的数据库?

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?

现在,当用户为自己创建一个新的实例时,我只需为他创建一个新的settings.py文件,并为其子域创建一个apache配置。现在当用户尝试访问他的实例时,他只能看到自己的数据库,所以我们完全分离数据。

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.

现在在尝试做背景时有一个问题同时拥有这些单独的数据库。后台进程应具体针对每个只对该实例数据进行操作的实例。 ZTask守护程序需要设置文件才能启动。问题是我必须为每个Django实例启动单独的ztaskd进程?或者我可以为所有实例启动一次ztaskd?

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 ?

提前感谢

推荐答案

ztaskd 在特定Django实例的上下文中工作,因此您不能为多个Django实例共享一个ZTask守护程序。

ztaskd works within a context of particular Django instance, so you cannot share one ZTask daemon for multiple Django instances.

您应该为每个具有本地设置的Django实例运行 ztaskd 。基本上开始使用

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 &

记住要有非冲突的 ZTASKD_URL 每个实例。对于本地的 ztaskd

Remember to have non-conflicting ZTASKD_URL for each instance. For local ztaskd

ZTASKD_URL = 'ipc:///tmp/%s_ztask.sock' % SITE_NAME

您以前的问题的答案是好主意。

这篇关于Django和SaaS + Ztask用于后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆