1
votes

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
I use this script to manage my ztaskd instances, but I don't have time to explain it ... hope this can be useful to inspire you gist.github.com/2585486 - jpic

1 Answers

0
votes

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.