Multitenants set up but not working [CLOSED]

HI all,
I have created a new instance of Bench - Frappe on a new server on Digital Ocean just to try the new development branch.

Everything fine during install.
Everything fine also later with bench update.
Now I have tried to install a second site using the following steps

bench new-site site2name
bench set-nginx-port site2name 82
bench setup nginx
sudo service nginx reload

no errors were given.

At this stage, I am not interested in setting up DNS.

site1.local on port 8000 works fine, now when I try site2name on port 82 nothing comes up.

I can see that during a bench update both sites are being updated.

So what am I missing and how can I check if all config files are setup properly?

Thanks in advance for the suggestions.

@Francois_Ifitwala

You will have to do,

bench setup production <user_name> (user_name = frappe) If you have setup your EPRNext using setup_frappe script.

1 Like

Thanks @shreyasp.

If I use user_name frappe I got this error

franky1@Multitenants:~$ bench setup production frappe
superuser privileges required for this command
franky1@Multitenants:~$ sudo bench setup production frappe
[sudo] password for franky1:
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 9, in
load_entry_point(‘bench==2.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/franky1/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/bench-repo/bench/commands/setup.py”, line 43, in setup_production
setup_production(user=user)
File “/home/franky1/bench-repo/bench/config/production_setup.py”, line 9, in setup_production
fix_prod_setup_perms(bench, frappe_user=user)
File “/home/franky1/bench-repo/bench/utils.py”, line 417, in fix_prod_setup_perms
uid = pwd.getpwnam(frappe_user).pw_uid
KeyError: ‘getpwnam(): name not found: frappe’

If I use user_name franky1 I got this other error

franky1@Multitenants:~$ sudo bench setup production franky1
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 9, in
load_entry_point(‘bench==2.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/franky1/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/bench-repo/bench/commands/setup.py”, line 43, in setup_production
setup_production(user=user)
File “/home/franky1/bench-repo/bench/config/production_setup.py”, line 20, in setup_production
os.symlink(os.path.abspath(os.path.join(bench, ‘config’, ‘supervisor.conf’)), supervisor_conf)
OSError: [Errno 17] File exists
franky1@Multitenants:~$

Now If I do bench update, it finishes the process with this error

Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
Migrating site1.local
Updating frappe : [========================================]
Updating erpnext : [========================================]
Migrating ifitwala
Updating frappe : [========================================]
Updating erpnext : [========================================]
Wrote ./assets/js/print_format_v3.min.js - 18k
Wrote ./assets/js/frappe-web.min.js - 107k
Wrote ./assets/js/form.min.js - 120k
Wrote ./assets/js/report.min.js - 157k
Wrote ./assets/js/erpnext.min.js - 38k
Wrote ./assets/css/list.min.css - 6k
Wrote ./assets/js/erpnext-web.min.js - 1k
Wrote ./assets/css/report.min.css - 7k
Wrote ./assets/css/frappe-web.css - 53k
Wrote ./assets/js/list.min.js - 67k
Wrote ./assets/js/dialog.min.js - 59k
Wrote ./assets/js/desk.min.js - 1084k
Wrote ./assets/css/form.min.css - 2k
Wrote ./assets/js/editor.min.js - 26k
Wrote ./assets/css/erpnext.css - 2k
Wrote ./assets/css/desk.min.css - 258k
Wrote ./assets/css/module.min.css - 2k
error: <class ‘xmlrpclib.Fault’>, <Fault 10: ‘BAD_NAME: frappe-bench-processes’>: file: /usr/lib/python2.7/xmlrpclib.py line: 794
error: <class ‘xmlrpclib.Fault’>, <Fault 10: ‘BAD_NAME: frappe’>: file: /usr/lib/python2.7/xmlrpclib.py line: 794
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==2.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/franky1/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/bench-repo/bench/commands/update.py”, line 61, in update
_update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
File “/home/franky1/bench-repo/bench/commands/update.py”, line 97, in _update
restart_supervisor_processes(bench=bench_path)
File “/home/franky1/bench-repo/bench/utils.py”, line 282, in restart_supervisor_processes
exec_cmd(‘sudo supervisorctl restart frappe:’, cwd=bench)
File “/home/franky1/bench-repo/bench/utils.py”, line 99, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: sudo supervisorctl restart frappe:
franky1@Multitenants:~$

@Francois_Ifitwala

Try doing bench setup sudoers <user_name> (franky1 in your case), since there is no user named frappe as per error that you have posted.

Also, rename supervisor.conf and nginx.conf before running bench setup production <user_name> (franky1 in your case)

Thanks a lot @shreyasp.
How would I change the name in nginx.conf and supervisor.conf?

@Francois_Ifitwala

Which name are trying to change or update in nginx or supervisor conf files ?

Hi @shreyasp,
Sorry I wasn’t clear. I was wondering how I do go about "rename supervisor.conf and nginx.conf " as suggested in your previous post.

@Francois_Ifitwala

To avoid error reported you should go to <bench-folder>/config and rename nginx.conf and supervisor.conf to something like nginx.conf.bak and supervisor.conf.bak and run following commands,

1. bench setup sudoers <user_name>
2. bench setup production <user_name>

Thanks @shreyasp, it seems like I’m getting the same error as before even after renaming.

Any idea?

franky1@Multitenants:~/frappe-bench/config$ mv nginx.conf nginx.conf.bak
franky1@Multitenants:~/frappe-bench/config$ mv supervisor.conf supervisor.conf.bak
franky1@Multitenants:~/frappe-bench/config$ bench setup sudoers franky1
superuser privileges required for this command
franky1@Multitenants:~/frappe-bench/config$ sudo bench setup sudoers franky1
[sudo] password for franky1:
franky1@Multitenants:~/frappe-bench/config$ sudo bench setup production franky1
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==2.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/franky1/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/bench-repo/bench/commands/setup.py”, line 43, in setup_production
setup_production(user=user)
File “/home/franky1/bench-repo/bench/config/production_setup.py”, line 20, in setup_production
os.symlink(os.path.abspath(os.path.join(bench, ‘config’, ‘supervisor.conf’)), supervisor_conf)
OSError: [Errno 17] File exists

@Francois_Ifitwala

My bad, I asked you to rename files on the wrong file path. Please rename files in the following path,

  • Nginx: /etc/nginx/conf.d/<bench_name>.conf or frappe.conf
  • Supervisor: /etc/{supervisor, supervisor.d, supervisord, supervisord.d}/<bench_name>.conf

Hope this helps you solve the error.

OK thanks … it seems like we managed to go further in the file but there are still some errors

franky1@Multitenants:/etc/nginx/conf.d$ sudo mv frappe-bench.conf frappe-bench.conf.bak
[sudo] password for franky1:
franky1@Multitenants:/etc/nginx/conf.d$ cd …/…/supervisor/
franky1@Multitenants:/etc/supervisor$ ls
conf.d supervisord.conf
franky1@Multitenants:/etc/supervisor$ sudo mv supervisord.conf supervisord.conf.bak
franky1@Multitenants:/etc/supervisor$ cd conf.d/
franky1@Multitenants:/etc/supervisor/conf.d$ ls
frappe-bench.conf
franky1@Multitenants:/etc/supervisor/conf.d$ sudo mv frappe-bench.conf frappe-bench.conf.bak
franky1@Multitenants:/etc/supervisor/conf.d$ cd …
franky1@Multitenants:/etc/supervisor$ ls
conf.d supervisord.conf.bak

and the error

franky1@Multitenants:~/frappe-bench$ sudo bench setup production franky1
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
error: <class ‘socket.error’>, [Errno 111] Connection refused: file: /usr/lib/python2.7/socket.py line: 571
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==2.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/franky1/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/bench-repo/bench/commands/setup.py”, line 43, in setup_production
setup_production(user=user)
File “/home/franky1/bench-repo/bench/config/production_setup.py”, line 23, in setup_production
exec_cmd(‘supervisorctl reload’)
File “/home/franky1/bench-repo/bench/utils.py”, line 99, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: supervisorctl reload
franky1@Multitenants:~/frappe-bench$

That said, It did a bench update without issue this time … weird :wink:

@Francois_Ifitwala

Please try executing following,

- sudo supervisorctl status
- sudo supervisorctl reread && sudo supervisorctl restart

1 Like

Thanks a lot @shreyasp for your patience.

Now I can run a bench update without error on both sites.

BUT, I do not have a site anymore on both port (8000 and 82). Not sure what other issues has been created when doing these things.

If I do

franky1@Multitenants:~$ sudo supervisorctl status
frappe-bench-redis:frappe-bench-redis-cache RUNNING pid 19683, uptime 15:24:51
frappe-bench-redis:frappe-bench-redis-queue RUNNING pid 19679, uptime 15:24:51
frappe-bench-redis:frappe-bench-redis-socketio RUNNING pid 19687, uptime 15:24:51
frappe-bench-web:frappe-bench-frappe-web RUNNING pid 19656, uptime 15:24:53
frappe-bench-web:frappe-bench-node-socketio RUNNING pid 19674, uptime 15:24:52
frappe-bench-workers:frappe-bench-frappe-default-worker-0 RUNNING pid 19673, uptime 15:24:52
frappe-bench-workers:frappe-bench-frappe-long-worker-0 RUNNING pid 19686, uptime 15:24:51
frappe-bench-workers:frappe-bench-frappe-schedule RUNNING pid 19624, uptime 15:24:55
frappe-bench-workers:frappe-bench-frappe-short-worker-0 RUNNING pid 19655, uptime 15:24:53

If I do:

franky1@Multitenants:~$ sudo supervisorctl reread && sudo supervisorctl restart
No config updates to processes
Error: restart requires a process name
restart Restart a process
restart :* Restart all processes in a group
restart Restart multiple processes or groups
restart all Restart all processes
Note: restart does not reread config files. For that, see reread and update.

And if I do

franky1@Multitenants:~$ bench doctor
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/franky1/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/franky1/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/franky1/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/home/franky1/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/franky1/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/franky1/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/franky1/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/franky1/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/frappe-bench/apps/frappe/frappe/commands.py”, line 852, in doctor
return _doctor(site=site)
File “/home/franky1/frappe-bench/apps/frappe/frappe/utils/doctor.py”, line 96, in doctor
workers_online = check_number_of_workers()
File “/home/franky1/frappe-bench/apps/frappe/frappe/utils/doctor.py”, line 85, in check_number_of_workers
return len(get_workers())
File “/home/franky1/frappe-bench/apps/frappe/frappe/utils/doctor.py”, line 10, in get_workers
with Connection(get_redis_conn()):
File “/home/franky1/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 136, in get_redis_conn
raise Exception(‘You need to call frappe.init’)
Exception: You need to call frappe.init

and if I try to reset my nginx, I get these issues.

franky1@Multitenants:~/frappe-bench$ sudo bench setup nginx
[sudo] password for franky1:
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 9, in
load_entry_point(‘bench==2.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/franky1/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/franky1/bench-repo/bench/commands/setup.py”, line 21, in setup_nginx
make_nginx_conf(bench_path=“.”)
File “/home/franky1/bench-repo/bench/config/nginx.py”, line 29, in make_nginx_conf
IOError: [Errno 13] Permission denied: ‘/home/franky1/frappe-bench/config/nginx.conf’
franky1@Multitenants:~/frappe-bench$

I’m sorry but I think the best thing to do would be to restart from scratch. There’s too many issues popping up and maybe there’s something wrong with the initial setup

Now, what we can do to create a new setup properly is this :

  1. Destroy this droplet and create a new Ubuntu droplet
  2. Use the setup_frappe script but with --setup-production
  3. Once setup is complete, do bench switch-to-develop
  4. Then do bench update
  5. Do bench config dns_multitenant off
  6. Add a new site, install apps
  7. Then do bench set-nginx-port [new-site-name] 81
  8. Then bench setup nginx
  9. Then sudo service nginx restart

That should do it

I think you have to check that’s is you have stopped Multitenant DNS mode

Hi @shreyasp,
Thanks again for all your help …
I had to restart the whole process from scratch… disappointing as I had started to put the initial data in that instance of erp.

Cheers