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

查看:50
本文介绍了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天全站免登陆