Multi tenant setup on bench

Hi,
I have installed frappe-bench on my local machine and created new-app library_management on it.

I tried to achieve multi-tenancy, I have done following steps


DNS based multitenancy mode is enabled
bench config dns_multitenant on

bench new-site library.dev
bench --site library.dev install-app library_management
bench use library.dev

bench new-site library.dev1
bench --site library.dev1 install-app library_management

bench new-site library.dev2
bench --site library.dev2 install-app library_management


I create 3 sites and installed library_management on it.
For above 3 sites [library.dev, library.dev1, library.dev2] it maintain separate database.

But issue is when I’m entering data in site
library.dev1:8000
same data is visible in library.dev:8000 and library.dev2:8000

May be it referring same database (default on) .

As per Multi tenant feature my thinking is it maintain separate database for each site, so that record created in one site(library.dev1) should not be visible in other site(library.dev2).

Please correct me if I miss some steps related to multi-tenancy, As I’m new to frappe framework, I want to explore more on it.

You need to be in production setup in order to have multitenant setup working…

@dinesh,

Please check the following https://github.com/frappe/bench/wiki/Multitenant-Setup to setup multitenancy.

Thank you all for reply.

I will test same thing in production environment and hope everything work fine…

@dinesh

You can actually run MultiTenant Setup for develop, however, you need to ensure that the host file is pointing to the correct development address.

A mistake I see in your setup is how you have named the different sites

instead of using library.dev, library.dev1, library.dev2 etc the common pattern with servers, addresses etc would be to use

library.dev, library1.dev library2.dev and so forth.

Here is the process I use when setting up Multi Tenant DNS
`

  1. bench config dns_multitenant on
  2. bench new-site library.dev
  3. bench setup nginx
  4. sudo service nginx reload
  5. bench --site library.dev install-app library-management
  6. Repeat steps 2 - 5 for every other site you wish to create
  7. To access the sites you will then use http://library.dev:8000, http://library1.dev:8000 and so forth
    `
    Ideally reboot the server just to ensure new settings are recognised.

Hope this helps

Hi,

I have followed below steps for Multi Tenant DNS

  1. bench config dns_multitenant on
  2. bench new-site library.dev
  3. bench setup nginx
  4. sudo service nginx reload
  5. bench --site library.dev install-app library-management
  6. Repeat steps 2 - 5 for every other site you wish to create
  7. To access the sites you will then use http://library.dev:8000, http://library1.dev:8000 and so forth

It working, in my local system having python version 2.7.6 and OS is ununtu 14.04


But when I am doing same thing in my production machine having python version 2.7.12+ and OS is ubuntu 16.04

after running below command

sudo bench setup production erpnext

It giving below error

supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/erpnext/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/bench-repo/bench/commands/setup.py”, line 56, in setup_production
setup_production(user=user)
File “/home/erpnext/bench-repo/bench/config/production_setup.py”, line 17, in setup_production
bench_name=bench_name, extn=supervisor_conf_extn))
File “/usr/lib/python2.7/posixpath.py”, line 70, in join
elif path == ‘’ or path.endswith(’/’):
AttributeError: ‘NoneType’ object has no attribute ‘endswith’

@dinesh

To switch to production mode on Ubuntu 16.10 following is what I did and you can follow the thread below.

frappe@erpnext:~/frappe-bench$ sudo supervisorctl reload
Restarted supervisord
frappe@erpnext:~/frappe-bench$ sudo service nginx start
frappe@erpnext:~/frappe-bench$ sudo bench setup production [USERNAME]
supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Port configuration list:

Site site1.local assigned port: 80
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
No config updates to processes
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
frappe@erpnext:~/frappe-bench$