Introduction
Welcome to this comprehensive guide on the Production Setup feature in Empress, a crucial tool for developers looking to optimize their software for real-world use. Understanding and effectively implementing this feature enhances the stability and reliability of your software, contributing significantly to business solution development.
A Closer Look at Production Setup
Production Setup in Empress refers to the process of configuring your software application to run optimally in a production environment. This feature primarily involves the use of two programs, Supervisor and Nginx. While Supervisor ensures the reliability of the system by keeping the process running and restarting them if a crash occurs, Nginx serves static files and proxies the rest of the requests to Empress.
Supervisor Configuration
Let’s first delve into the configuration of Supervisor. The role of Supervisor is to maintain system stability by keeping the Empress system processes running and restarting them when they crash.
You can generate the required configuration for Supervisor using the command bench setup supervisor
. The configuration will then be available in the config/supervisor.conf
directory. Copy or link this file to the supervisor config directory and reload it to apply the changes.
Here’s the command sequence:
bench setup supervisor
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf
Remember the following:
- Use the
--skip-redis
option if you do not need to generate config to start Redis servers. e.g.,bench setup supervisor --skip-redis
. - For CentOS 7, the extension should be
ini
, thus the command becomes:
bench setup supervisor
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.ini #for CentOS 7 only
To automate the process of restarting the processes managed by Supervisor when you update the apps, setup sudoers using the command, sudo bench setup sudoers $(whoami)
.
Nginx Configuration
Next, we’ll explore the configuration of Nginx. Nginx is a web server used to serve static files and proxy the rest of the requests to Empress.
Generate the required configuration for Nginx using the command bench setup nginx
. The configuration will be available in the config/nginx.conf
file. Copy or link this file to the Nginx config directory and reload it to apply the changes.
Here’s the command sequence:
bench setup nginx
sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf
Keep these points in mind:
- When you restart Nginx after the configuration change, it might fail if you have another configuration with server block as default for port 80. You will have to disable this config. Possible locations for it are
/etc/nginx/conf.d/default.conf
and/etc/nginx/conf.d/default
. In the latest Nginx installs, the file is in/etc/nginx/sites-available/default
.
Conclusion
The Production Setup feature is a vital part of software development, enabling developers to optimize their applications for real-world use. By correctly configuring Supervisor and Nginx, developers can ensure the reliability and performance of their software, contributing significantly to the creation and customization of business solutions. By mastering this feature, developers can effectively navigate the complexities of software development, delivering products that meet the highest standards of functionality and performance.