Developer mode and production mode

Hi, all

still have some confuse about developer mode and production mode. I installed Erpnext on my vm, using sudo bash setup_frappe.sh without --setup-production, after install steps, I have to run ‘bench start’ to run the server.
Then still on this vm I’d like to change it to production mode, so I did ‘bench setup supervisor/ngnix’ and ‘bench setup production erpnext’, then I don’t need do ‘bench start’ any more.
Now I have three questions:

  1. if I stop supervisorctl and bench start on this vm, does it mean it’s back to developer mode again?
    Once stop supervisor and start bench, it will go to developer mode, otherwise, reload supervisor and stop bench, it will go to production mode, is this understanding right?
  2. when I reloaded supervisor and stopped bench, I found the updated python code on the server will not compile to new pyc unless I execute ‘supervisorctl reload’, dose it mean it’s better to modify python code on server when bench start (developer mode)?
  3. when I use production mode, I found system is getting slower, seems gunicorn occupied 100% cpu, but when stop supervisor and bench start, system get right.

Any replies will be appreciated.

2 Likes

@Jasmine, developer_mode is not decided if you are running on nginx + supervisord, it is controlled by a key in your site_config.json, if it exists and is a true value, so you are in developer mode, since you are “Administrator”

The difference about bench start and nginx + supervisor from bench setup production is.

Nginx and Supervisor will run as daemon, forever, while do you need it running, or the server is alive, or you have, energy, disk etc.

bench start run threads that you can kill, and up easily while you change a file in backed, or are you doing core chages. It exists for you run your app, in your machine, or in a VM.

Nginx + Supervisor is for run in a long living server, usually the production server.

But I prefer a mix of both, only frappe-web running in bench start, and everything else runing in supervisor + nginx, since is more fast bench clear-cache instead of restart everything.

5 Likes

@max_morais_dmm Thanks your reply.
I ever read link Stop production which is about how to stop production mode and switch to developer mode. The reply from this link seems a little difference with your reply. According to that link, switch from production to developer should do:
cd frappe-bench
rm config/supervisor.conf
rm config/nginx.conf
service nginx stop
service supervisord stop
bench start
So I’m still very confused, which one is right or these two are different things?

@Jasmine, this discussion is a complemente of this discussion!

Developer Mode is a configuration option!
You can use nginx and supervisor in a instance that is with developer_mode on.

If do you need stop nginx and supervisor, follow the step in the link.

bench start is a alternative way to run the process that is managed by supervisor

2 Likes

@max_morais_dmm Thanks for your reply.
Another thing I’d like to know is:
you mentioned ‘a mix of both, only frappe-web running in bench start, and everything else runing in supervisor + nginx’ , how to do that?

@Jasmine I’m using my vagrant env, in Production mode, but I edited 2 files:

I removed the frappe:frappe-web in the file config/supervisor.conf, and on the file Procfile generated by bench setup procfile I removed everything except, the web: entry.

So, I can get everything running in the background and the frappe-web managed by bench start

4 Likes

hi @max_morais_dmm can you help me how to switch from developer to production mode is there anyway out?

I will use port 8888 for this example, but you can change that to the port number you prefer (as long as it is not already in use or reserved)

sudo bench setup production frappe
bench set-nginx-port site1.local 8888
#Site assigned port: 8888
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
bench setup nginx
sudo systemctl reload nginx

2 Likes

thanks @trentmu for your reply i got solution…!