Multi Bench Setup with DNS based multitenancy at Production Server. How To?

Hello Community,

I usually use Production Server with DNS based multitenancy, now as I learning development and getting involved in contributions. I required a Development Server as well, instead of multiple Development & Production Servers.

I had tried Multi Bench Setup wiki and successfully setup another bench as well. But, I’m not sure is it correct or not. My bench hierarchy is something like: /home/frappe/frappe-bench/new-bench and I can apply bench commands in new-bench as well.

But, when I tried to enable DNS based multitenancy at new-bench like subdomain.domain.com, while page shows only “Sorry! We will be back soon.” Currently, I’m trying with Production Server, also wants to keep Development & other Production Server both in new-bench1 and new-bench2 respectively.

Something like:
frappe-bench - Production
|-------------new-bench1=development
|-------------new-bench2=production1
|-------------new-bench3=production2

Is this achieveble? If yes, what special customization we required!! As @revant_one brother & @kolate_sambhaji bro tried to achieve it here: Multiple Bench Instance - #6 by revant_one

1 Like

It is not recomended to have production and development on same machine.
Maintain a separate server for production use.

You can have multiple development benches and bench start them as you need on a separate development machine.

alternatively, use vm or a docker.

1 Like

I have no luck to set two bench in one server

shl at DellT410 in /opt/ce
$ cat ces-bench/sites/common_site_config.json
{
“auto_update”: false,
“background_workers”: 1,
“file_watcher_port”: 6788,
“frappe_user”: “shl”,
“gunicorn_workers”: 8,
“rebase_on_pull”: false,
“redis_cache”: “redis://localhost:13001”,
“redis_queue”: “redis://localhost:11001”,
“redis_socketio”: “redis://localhost:12001”,
“restart_supervisor_on_update”: true,
“serve_default_site”: true,
“shallow_clone”: true,
“socketio_port”: 9001,
“update_bench_on_update”: true,
“webserver_port”: 8002

Other bench setting

shl at DellT410 in /opt/ce
$ cat ce-bench/sites/common_site_config.json
{
“auto_update”: false,
“background_workers”: 1,
“dns_multitenant”: false,
“file_watcher_port”: 6787,
“frappe_user”: “shl”,
“gunicorn_workers”: 8,
“rebase_on_pull”: false,
“redis_cache”: “redis://localhost:13000”,
“redis_queue”: “redis://localhost:11000”,
“redis_socketio”: “redis://localhost:12000”,
“restart_supervisor_on_update”: true,
“serve_default_site”: true,
“shallow_clone”: true,
“socketio_port”: 9000,
“update_bench_on_update”: true,
“webserver_port”: 8003
}

nginx is properly configured symlink to /etc/nginx/conf.d/ as well as supervisor. But when restarted nginx and supervisor the site on second bench unaccessible. OS ubuntu 16.04. When I stop supervisor, do bench start command in second bench and restart supervisor, both bench accessible and running well … :grinning:

1 Like

conf.d should contain ces-bench.conf and ce-bench.conf

What’s the status of supervisor?

sudo supervisorctl status

nginx setting

shl at DellT410 in ~
$ ls -n /etc/nginx/conf.d/
total 0
lrwxrwxrwx 1 0 0 25 Agu 20 16:24 bare.conf → sites-available/bare.conf
lrwxrwxrwx 1 0 0 34 Agu 11 04:08 ce-bench.conf → /opt/ce/ce-bench/config/nginx.conf
lrwxrwxrwx 1 0 0 35 Sep 20 04:47 ces-bench.conf → /opt/ce/ces-bench/config/nginx.conf

supervisor status

shl at DellT410 in ~
$ sudo supervisorctl status
ce-bench-redis:ce-bench-redis-cache RUNNING pid 25835, uptime 0:57:41
ce-bench-redis:ce-bench-redis-queue RUNNING pid 25834, uptime 0:57:41
ce-bench-redis:ce-bench-redis-socketio RUNNING pid 25833, uptime 0:57:41
ce-bench-web:ce-bench-frappe-web RUNNING pid 25832, uptime 0:57:41
ce-bench-web:ce-bench-node-socketio RUNNING pid 25831, uptime 0:57:41
ce-bench-workers:ce-bench-frappe-default-worker-0 RUNNING pid 25827, uptime 0:57:41
ce-bench-workers:ce-bench-frappe-long-worker-0 RUNNING pid 25830, uptime 0:57:41
ce-bench-workers:ce-bench-frappe-schedule RUNNING pid 25829, uptime 0:57:41
ce-bench-workers:ce-bench-frappe-short-worker-0 RUNNING pid 25828, uptime 0:57:41
ces-bench-redis:ces-bench-redis-cache FATAL Exited too quickly (process log may have details)
ces-bench-redis:ces-bench-redis-queue FATAL Exited too quickly (process log may have details)
ces-bench-redis:ces-bench-redis-socketio FATAL Exited too quickly (process log may have details)
ces-bench-web:ces-bench-frappe-web RUNNING pid 32069, uptime 0:00:06
ces-bench-web:ces-bench-node-socketio FATAL Exited too quickly (process log may have details)
ces-bench-workers:ces-bench-frappe-default-worker-0 RUNNING pid 25826, uptime 0:57:41
ces-bench-workers:ces-bench-frappe-long-worker-0 RUNNING pid 25823, uptime 0:57:41
ces-bench-workers:ces-bench-frappe-schedule RUNNING pid 25825, uptime 0:57:41
ces-bench-workers:ces-bench-frappe-short-worker-0 RUNNING pid 25824, uptime 0:57:41

both running by stop supervisor > do bench start in ces-bench and resatrt supervisor :slight_smile:

Can you check the ces-bench/logs and ce-bench/logs?
@x1123 start a new thread and link the post

Hello @revant_one !! Although, I agree. We should not maintain production & development together on the same machine. But, let’s change this query to a different mode.

Is this possible to achieve multiple only master branch of ERPNext, with multiple benches on the same instance? I came to know about Bench Manager App, so every bench should have this bench manager installed to easily maintain? Also, let’s say, by enabling multi-tenancy for each bench. How we manage?

Any tips for this kind of architecture? Oh, one more dumb question: Is there any difference between master branch & production server? Both are bit confusing for me. As I know, master branch is stable branch of ERPNext, which has only contains major releases like 8.9.0, 8.10.0, 8.11.0 or 9.0 etc. & production server which has master branch?? Am I correct?

Hi, I had tried to implement the same scenario as I asked earlier. What I did till, let me explain and help me out where I’m doing wrong.

So, I had installed ERPNext (production) and created one more bench into a frappe-bench directory by command bench init retail. Now, I came into the retail directory and enabled DNS based multitenancy bench config dns_multitenant on.

Now, I installed bench manager app, and also run bench setup nginx after installing app. Also, reloaded nginx as well. But, I can only see: Sorry! We will be back soon.

What I am missing? Any help !! Is I have to do same as mentioned here: How to setup a production and a development site next to each other - #12 by James_Robertson ?? How to??

Production Setup

Uses Supervisor and Nginx
All production benches are running with dns based mulitenancy
Create links to multiple frappe-bench-*.conf files under /etc/nginx/conf.d/ and /etc/supervisor/conf.d/
refer Setup Production

Developer Setup

In this case bench does not start automatically and you’ve to start it with bench start or bench serve (to start multiple sites)

Master Branch

This is the released stable code

Develop Branch

All the development happens here, you can help test the features on this branch. Feature contributions are sent to develop branch.

checkout to any branch in any setup.

Production server of an organization should be on master branch.

Developer setup depends on what is being developed.

Custom frappe apps released on production server should be on the same branch as production server.

If feature is developed to be sent as pull request, keep base as develop. Contribution Guidelines · frappe/erpnext Wiki · GitHub

2 Likes

Thanking you @revant_one !! Now, I’m a step forward with branches & server. Thanks a lot for these.

Now, one issue on the path i.e. whenever I’m trying to use mentioned commands, getting an error(as follows):

root@ip-xx-xx-xx-xx:/home/frappe/frappe-bench/retail# bench setup supervisor sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench-retail.conf
Error: no such option: -s

and same with nginx:

root@ip-xx-xx-xx-xx:/home/frappe/frappe-bench/retail# bench setup nginx sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench-retail.conf
Error: no such option: -s

Did I missed something again? I tried to get supervisorctl status and all are running(as follows):

root@ip-xx-xx-xx-xx:/home/frappe/frappe-bench/retail# sudo supervisorctl status
frappe-bench-redis:frappe-bench-redis-cache                 RUNNING   pid 1698, uptime 7:22:56
frappe-bench-redis:frappe-bench-redis-queue                 RUNNING   pid 1697, uptime 7:22:56
frappe-bench-redis:frappe-bench-redis-socketio              RUNNING   pid 1699, uptime 7:22:56
frappe-bench-web:frappe-bench-frappe-web                    RUNNING   pid 2343, uptime 7:16:13
frappe-bench-web:frappe-bench-node-socketio                 RUNNING   pid 2344, uptime 7:16:13
frappe-bench-workers:frappe-bench-frappe-default-worker-0   RUNNING   pid 2316, uptime 7:16:14
frappe-bench-workers:frappe-bench-frappe-long-worker-0      RUNNING   pid 2317, uptime 7:16:14
frappe-bench-workers:frappe-bench-frappe-schedule           RUNNING   pid 2315, uptime 7:16:14
frappe-bench-workers:frappe-bench-frappe-short-worker-0     RUNNING   pid 2318, uptime 7:16:14
1 Like

these are two separate commands

bench setup nginx

and

sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench-retail.conf
3 Likes

Oh, I see. Sorry for the silly mistake. @revant_one

Now, I’m stuck at unknown issue. Now, I can see both files:

  1. /etc/supervisor/conf.d/frappe-bench-retail.conf
  2. /etc/nginx/conf.d/frappe-bench-retail.conf

Now, still I’m redirecting to Sorry! We will be back soon. page. I should change something in /etc/nginx/conf.d/frappe-bench-retail.conf ?? or what next??

server {
        listen 80;
        server_name
                retail-bench.domain.com
                ;

        root /home/frappe/frappe-bench/retail/sites;

Should I change here? Some of developers(as mentioned already: How to setup a production and a development site next to each other - #12 by James_Robertson) using port as 8080, this make any difference? 80 was default port, I hadn’t changed anything yet.

I can see 3 points at Multi Bench Setup · frappe/bench Wiki · GitHub and have to hit these commands mentioned in point 3. But, before that, I should learn something.

  1. doesn’t applicable to me, because there is no file/dir named frappe_bench_dir.
  2. If server port doesn’t changed from 8000, then change it manually in nginx.conf and supervisor.conf. When I looked at frappe-bench/retail/sites/common_site_config.json, there is actually “webserver_port”: 8000. Should I change this value to 8001 & so on. Even if enabled DNS based multitenancy bench config dns_multitenant on ??
  3. For redis, change redis port, what should I put value for redis port and how will it go for further benches? Like we should go on 11001 or …???

My current frappe-bench/retail/sites/common_site_config.json file is as follows: (However, it is exactly same as frappe-bench/sites/common_site_config.json. Does it matter?)

{
 "auto_update": false,
 "background_workers": 1,
 "dns_multitenant": true,
 "file_watcher_port": 6787,
 "frappe_user": "root",
 "gunicorn_workers": 1,
 "rebase_on_pull": false,
 "redis_cache": "redis://localhost:13000",
 "redis_queue": "redis://localhost:11000",
 "redis_socketio": "redis://localhost:12000",
 "restart_supervisor_on_update": true,
 "serve_default_site": true,
 "shallow_clone": true,
 "socketio_port": 9000,
 "update_bench_on_update": true,
 "webserver_port": 8000
}

It should not be same.

change one of the file, and change all ports, e.g. 11000 to 11001, 12000 to 12001, 13000 to 13001, 9000 to 9001, 8000 to 8001
or use the command bench config --help to change these ports by command instead of manually.
after that run bench setup nginx and bench setup supervisor also restart/reload supervisor and nginx

2 Likes

Yeahhhhhhhh!!! Very happy to see login page this time. But… But, It’s again something I missing :roll_eyes:!!

Sorry @revant_one !! I tried to use bench config --help but, confused which command will auto-increment these values. So, I had changed them manually !! Everything worked fine, got login page instead of Sorry! We will be back soon.

But, Even while right login credentials, validations stucks at Verifying…!!
verifying-screen-stucked

Oh, Yes !! I used almost all commands !! Oh shitttttt, I had forgotten bench setup socketio.

I again hitted, these commands:

bench setup socketio
bench setup redis
service nginx reload
supervisorctl reload

&&&& You can’t imagine happiness over my face. I just shouted. Oh Yes…!!
Very Very Thankful to @revant_one !! Cheers !!

3 Likes

Hello @revant_one !!

Everything becomes fine, I created 2-3 benches for the test. All are working fine. Thereafter, I installed bench manager app as well. Goes fine.

On the another day, I tried to access all the benches with dns, One of the branch websites said “Site Error Occurred” while on the same bench, bench manager is working fine. However, I had get that site back by restarting & hit and trail.

One of another bench, site i.e. not accessible to me. I had tried harder to get it back but unfortunately not succeed. Site redirecting page to, “Sorry! We will be back soon.” I had tried even changing ports by increasing values to 11000…8000 to 8006 & so on !! Also, tried even copying back to /etc/supervisor/conf.d/frappe-bench-*.conf and completed that complete process.

No Clue, what to do/debug !! Now, I’m into debugging learning mode, eagerly waiting to learn these chapters as well.

see if you get any details by

sudo supervisorctl status

checkout logs

ls ~/<frappe-bench-dir>/logs/
1 Like

I think there is a mistake, use common sense in guide which spread out over internet. Main bench named “bench-repo” which we cloned first time. By using this bench-repo we init (create) another bench by default named “frappe-bench” if you wish to create TWO BENCH, first :

$ bench init frappe-bench

then create another bench

$ bench init frappe1-bench

and you can create hundred bench from one bench-repo, DO NOT create a bench inside the frappe-bench or frappe1-bench ( this is what named multi bench )

good lucks

1 Like