Install and Setup Bench
Bench is the command line tool to manage Frappe apps and sites.
Installation
If you haven't installed Bench, follow theInstallation guide. After installation, you should be able to run commands that start withbench
.
Run the following command to test your installation:
$ bench --version5.1.0
Create the frappe-bench directory
Let's create our project folder which will contain our apps and sites. Run the following command:
$ bench init frappe-bench
This will create a directory namedfrappe-bench
in your current working directory. It will do the following:
- Create a python virtual environment under
env
directory. - Fetch and install the
frappe
app as a python package. - Install node modules of
frappe
. - Build static assets.
Directory Structure
.├── Procfile├── apps│ └── frappe├── config│ ├── pids│ ├── redis_cache.conf│ ├── redis_queue.conf│ └── redis_socketio.conf├── env│ ├── bin│ ├── include│ ├── lib│ └── share├── logs│ ├── backup.log│ └── bench.log└── sites ├── apps.txt ├── assets └── common_site_config.json
- env: Python virtual environment
- config: Config files for Redis and Nginx
- logs: Log files for every process (web, worker)
sites: Sites directory
- assets: Static assets that served via Nginx in production
- apps.txt: List of installed frappe apps
- common_site_config.json: Site config that is available in all sites
apps: Apps directory
- frappe: The Frappe app directory
- Procfile: List of processes that run in development
Start the Bench Server
Now that we have created ourfrappe-bench
directory, we can start the Frappe web server by running the following command:
$ cd frappe-bench$ bench start18:16:36 system | redis_cache.1 started (pid=11231)18:16:36 system | redis_socketio.1 started (pid=11233)18:16:36 system | redis_queue.1 started (pid=11234)18:16:36 system | socketio.1 started (pid=11236)18:16:36 system | web.1 started (pid=11237)18:16:36 system | watch.1 started (pid=11240)18:16:36 system | schedule.1 started (pid=11241)18:16:36 system | worker_short.1 started (pid=11242)18:16:36 redis_queue.1 | 11234:C 10 Jul 2020 18:16:36.320 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18:16:36 redis_queue.1 | 11234:C 10 Jul 2020 18:16:36.320 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=11234, just started18:16:36 redis_queue.1 | 11234:C 10 Jul 2020 18:16:36.320 # Configuration loaded18:16:36 system | worker_long.1 started (pid=11244)18:16:36 redis_cache.1 | 11231:C 10 Jul 2020 18:16:36.318 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18:16:36 redis_cache.1 | 11231:C 10 Jul 2020 18:16:36.318 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=11231, just started18:16:36 redis_cache.1 | 11231:C 10 Jul 2020 18:16:36.318 # Configuration loaded18:16:36 redis_cache.1 | 11231:M 10 Jul 2020 18:16:36.320 * Increased maximum number of open files to 10032 (it was originally set to 256).18:16:36 redis_queue.1 | 11234:M 10 Jul 2020 18:16:36.325 * Increased maximum number of open files to 10032 (it was originally set to 256).18:16:36 system | worker_default.1 started (pid=11245)18:16:36 redis_cache.1 | 11231:M 10 Jul 2020 18:16:36.337 * Running mode=standalone, port=13000.18:16:36 redis_cache.1 | 11231:M 10 Jul 2020 18:16:36.337 # Server initialized18:16:36 redis_cache.1 | 11231:M 10 Jul 2020 18:16:36.337 * Ready to accept connections18:16:36 redis_queue.1 | 11234:M 10 Jul 2020 18:16:36.367 * Running mode=standalone, port=11000.18:16:36 redis_queue.1 | 11234:M 10 Jul 2020 18:16:36.367 # Server initialized18:16:36 redis_queue.1 | 11234:M 10 Jul 2020 18:16:36.367 * Ready to accept connections18:16:36 redis_socketio.1 | 11233:C 10 Jul 2020 18:16:36.359 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18:16:36 redis_socketio.1 | 11233:C 10 Jul 2020 18:16:36.359 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=11233, just started18:16:36 redis_socketio.1 | 11233:C 10 Jul 2020 18:16:36.359 # Configuration loaded18:16:36 redis_socketio.1 | 11233:M 10 Jul 2020 18:16:36.374 * Increased maximum number of open files to 10032 (it was originally set to 256).18:16:36 redis_socketio.1 | 11233:M 10 Jul 2020 18:16:36.417 * Running mode=standalone, port=12000.18:16:36 redis_socketio.1 | 11233:M 10 Jul 2020 18:16:36.418 # Server initialized18:16:36 redis_socketio.1 | 11233:M 10 Jul 2020 18:16:36.418 * Ready to accept connections18:16:37 socketio.1 | listening on *: 900018:16:41 web.1 | * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)18:16:41 web.1 | * Restarting with fsevents reloader18:16:41 watch.1 | yarn run v1.22.418:16:41 watch.1 | $ node rollup/watch.js18:16:42 watch.1 |18:16:42 watch.1 | Rollup Watcher Started18:16:42 watch.1 |18:16:42 watch.1 | Watching...18:16:42 web.1 | * Debugger is active!18:16:42 web.1 | * Debugger PIN: 100-672-92518:16:43 watch.1 | Rebuilding frappe-web-b4.css18:16:44 watch.1 | Rebuilding frappe-chat-web.css18:16:44 watch.1 | Rebuilding chat.js18:16:45 watch.1 | Rebuilding frappe-recorder.min.js18:16:48 watch.1 | Rebuilding checkout.min.js18:16:48 watch.1 | Rebuilding frappe-web.min.js18:16:51 watch.1 | Rebuilding bootstrap-4-web.min.js18:16:52 watch.1 | Rebuilding control.min.js18:16:54 watch.1 | Rebuilding dialog.min.js18:16:57 watch.1 | Rebuilding desk.min.css18:16:57 watch.1 | Rebuilding frappe-rtl.css18:16:58 watch.1 | Rebuilding printview.css18:16:58 watch.1 | Rebuilding desk.min.js18:17:04 watch.1 | Rebuilding form.min.css18:17:04 watch.1 | Rebuilding form.min.js18:17:07 watch.1 | Rebuilding list.min.css18:17:07 watch.1 | Rebuilding list.min.js18:17:09 watch.1 | Rebuilding report.min.css18:17:09 watch.1 | Rebuilding report.min.js18:17:12 watch.1 | Rebuilding web_form.min.js18:17:12 watch.1 | Rebuilding web_form.css18:17:13 watch.1 | Rebuilding email.css18:17:13 watch.1 | Rebuilding social.min.js18:17:13 watch.1 | Rebuilding barcode_scanner.min.js18:17:15 watch.1 | Rebuilding data_import_tools.min.js
This will start several processes including a Python web server based on Gunicorn, redis servers for caching, job queuing and socketio pub-sub, background workers, node server for socketio and a node server for compiling JS/CSS files.
The web server will start listening on the port8000
but we don't have any sites yet to serve. Our next step is to create our app and create a site that will have this app installed.
Make sure not to close the terminal wherebench start
is running. To run bench commands, create another terminal and cd into thefrappe-bench
directory.
Good job on following the tutorial so far!
Next:Create an App