This is not for beginners. This is for people who wish to understand bench.
Following steps assume python 3, nodejs, yarn, mariadb, redis and other dependencies are manually installed
Setup directory structure
mkdir benchless && cd benchless
mkdir -p apps logs sites
Setup Python environment
python -m venv env
git clone https://github.com/frappe/frappe apps/frappe --depth 1 --branch develop
./env/bin/pip install --no-cache-dir -e apps/frappe
git clone https://github.com/frappe/erpnext apps/erpnext --depth 1 --branch develop
./env/bin/pip install --no-cache-dir -e apps/erpnext
echo -e "frappe\nerpnext" > sites/apps.txt
Setup NodeJs dependencies
yarn --cwd apps/frappe
Create bench_helper and make it executable
nano bench_helper
Add following lines to the file
#!/bin/sh
export script_dir="$(dirname "$0")"
cd $script_dir/sites
../env/bin/python ../apps/frappe/frappe/utils/bench_helper.py frappe "$@"
Make the file executable
chmod +x bench_helper
Use bench commands
./bench_helper --help
Build static assets
./bench_helper build
Add common_site_config.json for specifying hosts
nano sites/common_site_config.json
Add following lines
{
"db_host": "0.0.0.0",
"db_port": 3306,
"redis_cache": "redis://localhost:13000",
"redis_queue": "redis://localhost:11000",
"redis_socketio": "redis://localhost:12000"
}
Start processes with honcho
# Install honcho
./env/bin/pip install honcho
# Edit Procfile
nano Procfile
Add following lines
redis_cache: redis-server --port 13000
redis_socketio: redis-server --port 12000
redis_queue: redis-server --port 11000
socketio: node apps/frappe/socketio.js
web: ./bench_helper serve --port 8000
watch: ./bench_helper watch
schedule: ./bench_helper schedule
worker_short: ./bench_helper worker --queue short
worker_long: ./bench_helper worker --queue long
worker_default: ./bench_helper worker --queue default
start processes
./env/bin/honcho start
Start mariadb
Apply frappe specific config for mariadb. e.g. frappe.cnf
sudo systemctl start mariadb.service
Create new site
./bench_helper new-site mysite.localhost --install-app erpnext
Drop site
./bench_helper drop-site mysite.localhost