How to switch development to production?

In my server i doing one setup that is development ,but i want to switch that on production so how to do that…?? without loose any data?

To switch branches from say master to develop in the same environment yes you risk losing data.

One sure option is this Backup & Restore

Another option is to run a VM and clone a new copy.

2 Likes

thanks for informing

Actually I should correct that:

To switch master (aka production) to develop, there’s little risk of losing data, since one is advancing with code changes, where patches are designed handle data migration.

But to go the other way - from develop to production - can pose a problem since one is returning to an earlier version and there is no mechanism to unpatch migrated data.

1 Like

I have clone but some issue .on giving bench start it is not start ,through the error bench command not found …
also install bench-repo but nothing happen still issue is same so is there any another approach for the production setup.

“is there any another approach for the production setup”

Best to do a fresh install then restore your data backed up from another instance to the new one.

For specific errors that occur search the forum and you will find answers.

1 Like

i also do that but having some issue in that

18:00:04 system | worker_long.1 started (pid=15525)
18:00:04 system | redis_socketio.1 started (pid=15526)
18:00:04 system | schedule.1 started (pid=15529)
18:00:04 system | watch.1 started (pid=15530)
18:00:04 system | web.1 started (pid=15523)
18:00:04 redis_socketio.1 | 15531:C 11 Oct 2019 18:00:04.490 # Can’t chdir to ‘/home/satish/frappe-bench/config/pids’: No such file or directory
18:00:04 system | redis_socketio.1 stopped (rc=1)
18:00:04 system | socketio.1 started (pid=15540)
18:00:04 system | worker_short.1 started (pid=15546)
18:00:04 system | redis_cache.1 started (pid=15543)
18:00:04 redis_cache.1 | 15549:C 11 Oct 2019 18:00:04.501 # Can’t chdir to ‘/home/satish/frappe-bench/config/pids’: No such file or directory
18:00:04 system | redis_cache.1 stopped (rc=1)
18:00:04 system | worker_default.1 started (pid=15537)
18:00:04 system | redis_queue.1 started (pid=15522)
18:00:04 system | sending SIGTERM to worker_long.1 (pid 15525)
18:00:04 system | sending SIGTERM to watch.1 (pid 15530)
18:00:04 system | sending SIGTERM to redis_queue.1 (pid 15522)
18:00:04 system | sending SIGTERM to web.1 (pid 15523)
18:00:04 system | sending SIGTERM to schedule.1 (pid 15529)
18:00:04 system | sending SIGTERM to worker_default.1 (pid 15537)
18:00:04 system | sending SIGTERM to socketio.1 (pid 15540)
18:00:04 system | sending SIGTERM to worker_short.1 (pid 15546)
18:00:04 system | worker_long.1 stopped (rc=-15)
18:00:04 system | web.1 stopped (rc=-15)
18:00:04 system | schedule.1 stopped (rc=-15)
18:00:04 system | watch.1 stopped (rc=-15)
18:00:04 system | socketio.1 stopped (rc=-15)
18:00:04 system | redis_queue.1 stopped (rc=-15)
18:00:04 system | worker_short.1 stopped (rc=-15)
18:00:04 system | worker_default.1 stopped (rc=-15)

How odd this is missing:

/home/satish/frappe-bench/config/pids’: No such file or directory.

I have one that is empty:

frappe@ubuntu:~/frappe-bench$ ls -al config/pids/
total 8
drwxr-xr-x 2 frappe frappe 4096 Mar  9  2018 .
drwxr-xr-x 3 frappe frappe 4096 Mar  9  2018 ..

Perhaps do a mkdir config/pids and see what happens

1 Like

ls: cannot access ‘config/pids/’: No such file or directory

Development mode uses werkzeug

In development mode, you use:

 bench start

to start Redis and Werkzeug.

On the client side, you use

  http://localhost:8000 

to access the erpnext / frappe site that you started on the server.

To stop the server in development mode, just press Ctrl-C on the server terminal.

Production mode uses Supervisor and Nginx.

To switch to production mode, you enter the following commands (one time only):

 bench setup supervisor
 sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf
  sudo bench setup sudoers $(whoami)

The first command activates supervisor, and the second command will start supervisor every time you boot up. The third command automates this startup.

Then, you enter the following commands below to activate Nginx and restart it also every time you boot up.

  bench setup nginx
  sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf

To see if Supervisor and Nginx are running, you use:

   sudo service supervisor status

   sudo service nginx status

The outputs will show if supervisor and nginx are ACTIVE.

On the client site, you use

   http://localhost   (no more port)

If you want to stop production mode, and start the server in development mode again, you use the following commands:

    sudo service supervisor stop
    sudo service nginx stop

The two commands above stops the supervisor (which runs the redis server), and nginx web server.

You can now issue the development mode command:

    bench start

To go back to production mode, just stop the development mode server using Ctrl-C and issue the following commands:

     sudo service supervisor start
     sudo service nginx start

You are back to production mode.

It is good to remember that at this stage, every time you boot up the server, Erpnext / Frappe is already running in production mode. So, if you want to start the development mode server, you must issue the commands:

      sudo service supervisor stop      
      sudo service nginx stop
      bench start

to stop the production mode server and start the development mode server.

5 Likes

i also do that but whenever i try to run bench start it gives an error

22:18:23 system | redis_cache.1 started (pid=6391)
22:18:24 system | socketio.1 started (pid=6392)
22:18:24 system | redis_socketio.1 started (pid=6382)
22:18:24 system | worker_default.1 started (pid=6389)
22:18:24 system | redis_queue.1 started (pid=6388)
22:18:24 redis_queue.1 | 6395:C 11 Oct 2019 22:18:24.000 # Can’t chdir to ‘/home/satish/frappe-bench/config/pids’: No such file or directory
22:18:24 system | redis_queue.1 stopped (rc=1)
22:18:24 redis_cache.1 | 6393:C 11 Oct 2019 22:18:24.004 # Can’t chdir to ‘/home/satish/frappe-bench/config/pids’: No such file or directory
22:18:24 system | redis_cache.1 stopped (rc=1)
22:18:24 system | watch.1 started (pid=6384)
22:18:24 socketio.1 | /bin/sh: 1: /home/satish/.nvm/versions/node/v8.16.1/bin/node: not found
22:18:24 system | schedule.1 started (pid=6408)
22:18:24 system | socketio.1 stopped (rc=127)
22:18:24 redis_socketio.1 | 6397:C 11 Oct 2019 22:18:24.011 # Can’t chdir to ‘/home/satish/frappe-bench/config/pids’: No such file or directory
22:18:24 system | redis_socketio.1 stopped (rc=1)
22:18:24 system | worker_long.1 started (pid=6390)
22:18:24 system | web.1 started (pid=6409)
22:18:24 system | worker_short.1 started (pid=6403)
22:18:24 system | sending SIGTERM to worker_long.1 (pid 6390)
22:18:24 system | sending SIGTERM to watch.1 (pid 6384)
22:18:24 system | sending SIGTERM to web.1 (pid 6409)
22:18:24 system | sending SIGTERM to schedule.1 (pid 6408)
22:18:24 system | sending SIGTERM to worker_default.1 (pid 6389)
22:18:24 system | sending SIGTERM to worker_short.1 (pid 6403)
22:18:24 system | watch.1 stopped (rc=-15)
22:18:24 system | schedule.1 stopped (rc=-15)
22:18:24 system | web.1 stopped (rc=-15)
22:18:24 system | worker_short.1 stopped (rc=-15)
22:18:24 system | worker_default.1 stopped (rc=-15)
22:18:24 system | worker_long.1 stopped (rc=-15)

You may set up production mode using:

 bench setup production frappe

(frappe is the non-root username. You may change it to frappe-erp, frappe-user or whatever you like).

Make frappe a sudo user.

 sudo usermod -aG sudo frappe

Give frappe a password

 sudo passwd frappe

Use frappe user to activate Erpnext / frapp

 su - frappe

(enter the password of frappe that you gave in passwd frappe)

Note that the home directory has changed to /home/frappe

 cd frappe-bench

run your bench commands in this directory which is now /home/frappe/frappe-bench.

(I see that your home directory is still /home/satish)

Caution: frappe is an overused user name for this purpose. It is recommended that you use another user name - for example: erpsatish. In this case, you use

  bench setup production erpsatish
2 Likes

ref,

this solution gives a “return to zero” error.

Ok contact Instagram : tech.hacktamil