Production Setup
Bench is the command-line tool used to deploy, manage, and maintain Frappe Framework applications in production. It simplifies tasks such as creating sites, installing apps, configuring services, managing updates, and handling production deployments.
Overview
A typical production deployment consists of installing Bench, creating a site, installing applications, verifying background services, and performing regular updates. Bench automates much of this setup for supported Linux distributions.
Step 1: Install Bench
If you’re deploying on a supported Linux distribution such as Ubuntu, Debian, or CentOS, you can use the Easy Install script. Be sure to include the --production flag during installation.
sudo python install.py --production --user [frappe-user]
This installs Bench and prepares the environment for running production-ready Frappe applications.
Step 2: Create a Site and Install Applications
After installing Bench, navigate to your bench directory, create a new site, download the required applications, and install them.
# Change to the bench directory
cd frappe-bench
# Create a new site
bench new-site example.com
# Download applications
bench get-app erpnext
bench get-app https://github.com/yourremote/yourapp.git
# Install applications on the site
bench --site example.com install-app erpnext yourapp
Once installation is complete, your site is ready to be served by the production services.
Step 3: Verify Supervisor Services
Bench uses Supervisor to manage production processes such as Redis, workers, scheduling, Socket.IO, and the web server.
Verify that every required service is running:
sudo supervisorctl status
A healthy deployment should show services similar to the following:
frappe-bench-redis:frappe-bench-redis-cache RUNNING
frappe-bench-redis:frappe-bench-redis-queue RUNNING
frappe-bench-redis:frappe-bench-redis-socketio RUNNING
frappe-bench-web:frappe-bench-frappe-web RUNNING
frappe-bench-web:frappe-bench-node-socketio RUNNING
frappe-bench-workers:frappe-bench-frappe-default-worker-0 RUNNING
frappe-bench-workers:frappe-bench-frappe-long-worker-0 RUNNING
frappe-bench-workers:frappe-bench-frappe-schedule RUNNING
frappe-bench-workers:frappe-bench-frappe-short-worker-0 RUNNING
If your domain (for example, example.com) points to your server’s IP address and all Supervisor services are running, your Frappe site should be accessible from the browser.
Updating a Production Bench
Bench provides a single command to keep your production environment up to date. Depending on your requirements, you can update the entire bench or only specific components.
| Command | Description |
|---|---|
bench update |
Performs a complete update, including pulling code, applying patches, building assets, and restarting services. |
bench update --pull |
Downloads the latest application code only. |
bench update --patch |
Runs database migrations and patches without pulling code. |
bench update --build |
Rebuilds JavaScript and CSS assets only. |
bench update --bench |
Updates the Bench CLI itself. |
bench update --requirements |
Updates Python packages and Node.js dependencies. |
Redis Namespaces
Redis namespaces improve security and allow multiple Bench instances to share the same Redis server without key collisions. Bench can automatically create Redis users and configure queue authentication.
Create Redis Queue Users
bench create-rq-users
# Optional flags
# --use-rq-auth
# --set-admin-password
The command generates an Access Control List (ACL) file inside the Bench configuration directory.
Configure Redis Queue
Ensure that your redis_queue.conf file references the generated ACL file:
aclfile [frappe-bench-absolute-path]/config/redis_queue.acl
If the ACL configuration is missing, regenerate the Redis configuration using:
bench setup redis
Best Practice
Always verify Supervisor services after deployment or updates. Before running bench update on production, take a complete site backup and test updates in a staging environment whenever possible. If multiple benches share a Redis server, enable Redis namespaces to improve security and prevent key conflicts.