Code Monkey home page Code Monkey logo

bench's Introduction

Bench

Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications on *nix systems for development and production.

Table of Contents

Installation

A typical bench setup provides two types of environments โ€” Development and Production.

The setup for each of these installations can be achieved in multiple ways:

We recommend using Docker Installation to setup a Production Environment. For Development, you may choose either of the two methods to setup an instance.

Otherwise, if you are looking to evaluate Frappe apps without hassle of hosting, you can try them on frappecloud.com.

Containerized Installation

A Frappe/ERPNext instance can be setup and replicated easily using Docker. The officially supported Docker installation can be used to setup either of both Development and Production environments.

To setup either of the environments, you will need to clone the official docker repository:

$ git clone https://github.com/frappe/frappe_docker.git
$ cd frappe_docker

A quick setup guide for both the environments can be found below. For more details, check out the Frappe/ERPNext Docker Repository.

Easy Install Script

The Easy Install script should get you going with a Frappe/ERPNext setup with minimal manual intervention and effort.

This script uses Docker with the Frappe/ERPNext Docker Repository and can be used for both Development setup and Production setup.

Setup

Download the Easy Install script and execute it:

$ wget https://raw.githubusercontent.com/frappe/bench/develop/easy-install.py
$ python3 easy-install.py --prod --email [email protected]

This script will install docker on your system and will fetch the required containers, setup bench and a default ERPNext instance.

The script will generate MySQL root password and an Administrator password for the Frappe/ERPNext instance, which will then be saved under $HOME/passwords.txt of the user used to setup the instance. It will also generate a new compose file under $HOME/<project-name>-compose.yml.

When the setup is complete, you will be able to access the system at http://<your-server-ip>, wherein you can use the Administrator password to login.

Arguments

Here are the arguments for the easy-install script

usage: easy-install.py [-h] [-p] [-d] [-s SITENAME] [-n PROJECT] [--email EMAIL]

Install Frappe with Docker

options:
  -h, --help            		show this help message and exit
  -p, --prod            		Setup Production System
  -d, --dev             		Setup Development System
  -s SITENAME, --sitename SITENAME      The Site Name for your production site
  -n PROJECT, --project PROJECT         Project Name
  --email EMAIL         		Add email for the SSL.

Troubleshooting

In case the setup fails, the log file is saved under $HOME/easy-install.log. You may then

  • Create an Issue in this repository with the log file attached.

Manual Installation

Some might want to manually setup a bench instance locally for development. To quickly get started on installing bench the hard way, you can follow the guide on Installing Bench and the Frappe Framework.

You'll have to set up the system dependencies required for setting up a Frappe Environment. Checkout docs/installation for more information on this. If you've already set up, install bench via pip:

$ pip install frappe-bench

Basic Usage

Note: Apart from bench init, all other bench commands are expected to be run in the respective bench directory.

  • Create a new bench:

    $ bench init [bench-name]
  • Add a site under current bench:

    $ bench new-site [site-name]
    • Optional: If the database for the site does not reside on localhost or listens on a custom port, you can use the flags --db-host to set a custom host and/or --db-port to set a custom port.

       $ bench new-site [site-name] --db-host [custom-db-host-ip] --db-port [custom-db-port]
  • Download and add applications to bench:

    $ bench get-app [app-name] [app-link]
  • Install apps on a particular site

    $ bench --site [site-name] install-app [app-name]
  • Start bench (only for development)

    $ bench start
  • Show bench help:

    $ bench --help

For more in-depth information on commands and their usage, follow Commands and Usage. As for a consolidated list of bench commands, check out Bench Usage.

Custom Bench Commands

If you wish to extend the capabilities of bench with your own custom Frappe Application, you may follow Adding Custom Bench Commands.

Guides

For an exhaustive list of guides, check out Bench Guides.

Resources

For an exhaustive list of resources, check out Bench Resources.

Development

To contribute and develop on the bench CLI tool, clone this repo and create an editable install. In editable mode, you may get the following warning everytime you run a bench command:

WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
$ git clone https://github.com/frappe/bench ~/bench-repo
$ pip3 install -e ~/bench-repo
$ bench src
/Users/frappe/bench-repo

To clear up the editable install and switch to a stable version of bench, uninstall via pip and delete the corresponding egg file from the python path.

# Delete bench installed in editable install
$ rm -r $(find ~ -name '*.egg-info')
$ pip3 uninstall frappe-bench

# Install latest released version of bench
$ pip3 install -U frappe-bench

To confirm the switch, check the output of bench src. It should change from something like $HOME/bench-repo to /usr/local/lib/python3.6/dist-packages and stop the editable install warnings from getting triggered at every command.

Releases

Bench's version information can be accessed via bench.VERSION in the package's init.py file. Eversince the v5.0 release, we've started publishing releases on GitHub, and PyPI.

GitHub: https://github.com/frappe/bench/releases

PyPI: https://pypi.org/project/frappe-bench

From v5.3.0, we partially automated the release process using @semantic-release. Under this new pipeline, we do the following steps to make a release:

  1. Merge develop into the staging branch
  2. Merge staging into the latest stable branch, which is v5.x at this point.

This triggers a GitHub Action job that generates a bump commit, drafts and generates a GitHub release, builds a Python package and publishes it to PyPI.

The intermediate staging branch exists to mediate the bench.VERSION conflict that would arise while merging develop and stable. On develop, the version has to be manually updated (for major release changes). The version tag plays a role in deciding when checks have to be made for new Bench releases.

Note: We may want to kill the convention of separate branches for different version releases of Bench. We don't need to maintain this the way we do for Frappe & ERPNext. A single branch named stable would sustain.

License

This repository has been released under the GNU GPLv3 License.

bench's People

Contributors

18alantom avatar abhishekbalam avatar achillesrasquinha avatar adamtang79 avatar adityahase avatar akhilnarang avatar anandpdoshi avatar ankush avatar aradhya-tripathi avatar athul avatar barredterra avatar casesolved-co-uk avatar ceefour avatar codingcoffee avatar dulhaver avatar gavindsouza avatar nabinhait avatar netchampfaris avatar pdvyas avatar revant avatar rmehta avatar rtdany10 avatar sagarvora avatar sahil28297 avatar saurabh6790 avatar saxenabhishek avatar shridarpatil avatar surajshetty3416 avatar thunderbottom avatar vjfalk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bench's Issues

error in update

fourmax@fourmax-To-be-filled-by-O-E-M:~/frappe-bench$ ./scripts/update.sh
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 2), reused 4 (delta 2)
Unpacking objects: 100% (6/6), done.
From https://github.com/frappe/frappe-bench
135efaa..72f8191 master -> origin/master
Updating 135efaa..72f8191
Fast-forward
Readme.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
updating apps/erpnext
remote: Counting objects: 2403, done.
remote: Compressing objects: 100% (1067/1067), done.
remote: Total 2403 (delta 1677), reused 1808 (delta 1317)
Receiving objects: 100% (2403/2403), 2.27 MiB | 56.00 KiB/s, done.
Resolving deltas: 100% (1677/1677), done.
From https://github.com/frappe/erpnext

  • branch HEAD -> FETCH_HEAD
    First, rewinding head to replay your work on top of it...
    Fast-forwarded develop to b748115609bd07f52aea82afaed40cff07889ca9.
    /home/fourmax/frappe-bench
    updating apps/frappe
    remote: Counting objects: 2258, done.
    remote: Compressing objects: 100% (1013/1013), done.
    remote: Total 2258 (delta 1517), reused 1728 (delta 1230)
    Receiving objects: 100% (2258/2258), 2.00 MiB | 52.00 KiB/s, done.
    Resolving deltas: 100% (1517/1517), done.
    From https://github.com/frappe/frappe
  • branch HEAD -> FETCH_HEAD
    First, rewinding head to replay your work on top of it...
    Fast-forwarded develop to 0fcfad56ebfb82a352878743d1cf3ba0765dff89.
    /home/fourmax/frappe-bench
    updating apps/shopping_cart
    remote: Counting objects: 53, done.
    remote: Compressing objects: 100% (52/52), done.
    remote: Total 53 (delta 12), reused 16 (delta 1)
    Unpacking objects: 100% (53/53), done.
    From https://github.com/frappe/shopping-cart
  • branch HEAD -> FETCH_HEAD
    First, rewinding head to replay your work on top of it...
    Fast-forwarded develop to c39b630dd0237295f43c50c60e21a659db8ff8aa.
    /home/fourmax/frappe-bench
    Traceback (most recent call last):
    File "/home/fourmax/frappe-bench/env/bin/frappe", line 9, in
    load_entry_point('frappe==4.1.0', 'console_scripts', 'frappe')()
    File "/home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py", line 353, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
    File "/home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py", line 2302, in load_entry_point
    return ep.load()
    File "/home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py", line 2029, in load
    entry = import(self.module_name, globals(),globals(), ['name'])
    File "/home/fourmax/frappe-bench/apps/frappe/frappe/init.py", line 15, in
    from .utils.jinja import get_jenv, get_template, render_template
    File "/home/fourmax/frappe-bench/apps/frappe/frappe/utils/init.py", line 12, in
    from frappe.utils.data import *
    File "/home/fourmax/frappe-bench/apps/frappe/frappe/utils/data.py", line 10, in
    import babel.dates
    ImportError: No module named babel.dates
    fourmax@fourmax-To-be-filled-by-O-E-M:~/frappe-bench$ ./scripts/update.sh
    Already up-to-date.
    updating apps/erpnext
    From https://github.com/frappe/erpnext
  • branch HEAD -> FETCH_HEAD
    Current branch develop is up to date.
    /home/fourmax/frappe-bench
    updating apps/frappe
    From https://github.com/frappe/frappe
  • branch HEAD -> FETCH_HEAD
    Current branch develop is up to date.
    /home/fourmax/frappe-bench
    updating apps/shopping_cart
    From https://github.com/frappe/shopping-cart
  • branch HEAD -> FETCH_HEAD
    Current branch develop is up to date.
    /home/fourmax/frappe-bench
    Traceback (most recent call last):
    File "/home/fourmax/frappe-bench/env/bin/frappe", line 9, in
    load_entry_point('frappe==4.1.0', 'console_scripts', 'frappe')()
    File "/home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py", line 353, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
    File "/home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py", line 2302, in load_entry_point
    return ep.load()
    File "/home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/pkg_resources.py", line 2029, in load
    entry = import(self.module_name, globals(),globals(), ['name'])
    File "/home/fourmax/frappe-bench/apps/frappe/frappe/init.py", line 15, in
    from .utils.jinja import get_jenv, get_template, render_template
    File "/home/fourmax/frappe-bench/apps/frappe/frappe/utils/init.py", line 12, in
    from frappe.utils.data import *
    File "/home/fourmax/frappe-bench/apps/frappe/frappe/utils/data.py", line 10, in
    import babel.dates
    ImportError: No module named babel.dates

static log in page

when i open http://0.0.0.0:8000/
i see page withe more than one login form
html only i cant' access any thing
just static page

fourmax@fourmax-To-be-filled-by-O-E-M:~/frappe-bench$ bench start
11:38:31 web.1 | started with pid 3605
11:38:31 worker.1 | started with pid 3606
11:38:31 workerbeat.1 | started with pid 3608
11:38:31 web.1 | * Running on http://0.0.0.0:8000/
11:38:31 web.1 | * Restarting with reloader
11:38:31 workerbeat.1 | Stale pidfile exists. Removing it.
11:38:31 workerbeat.1 | [2014-07-17 11:38:31,601: INFO/MainProcess] beat: Starting...
11:38:31 workerbeat.1 | [2014-07-17 11:38:31,647: INFO/MainProcess] Scheduler: Sending due task scheduler (frappe.tasks.enqueue_scheduler_events)
11:38:32 worker.1 | [2014-07-17 11:38:32,619: WARNING/MainProcess] /home/fourmax/frappe-bench/env/local/lib/python2.7/site-packages/celery/app/control.py:36: DuplicateNodenameWarning: Received multiple replies from node name: 'name'.
11:38:32 worker.1 | Please make sure you give each node a unique nodename using the -n option.
11:38:32 worker.1 | pluralize(len(dupes), 'name'), ', '.join(sorted(dupes)),
11:38:32 worker.1 | [2014-07-17 11:38:32,633: WARNING/MainProcess] celery@fourmax-To-be-filled-by-O-E-M ready.
11:38:54 web.1 | 127.0.0.1 - - [17/Jul/2014 11:38:54] "GET / HTTP/1.1" 200 -
11:38:54 web.1 | 127.0.0.1 - - [17/Jul/2014 11:38:54] "GET /assets/frappe/js/lib/jquery/jquery.min.js HTTP/1.1" 404 -
11:38:54 web.1 | 127.0.0.1 - - [17/Jul/2014 11:38:54] "GET /assets/css/frappe-web.css HTTP/1.1" 404 -
11:38:54 web.1 | 127.0.0.1 - - [17/Jul/2014 11:38:54] "GET /assets/js/frappe-web.min.js HTTP/1.1" 404 -
11:38:54 web.1 | 127.0.0.1 - - [17/Jul/2014 11:38:54] "GET /style_settings.css HTTP/1.1" 200 -
11:38:54 web.1 | 127.0.0.1 - - [17/Jul/2014 11:38:54] "GET /website_script.js HTTP/1.1" 200 -

error bench start

command bench start cause error:

Traceback (most recent call last):
File "/usr/local/bin/bench", line 9, in
load_entry_point('bench==0.1', 'console_scripts', 'bench')()
File "/home/fourmax/bench/bench/cli.py", line 24, in cli
return bench()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 488, in call
return self.main(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 474, in main
self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 758, in invoke
return self.invoke_subcommand(ctx, cmd, cmd_name, ctx.args[1:])
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 767, in invoke_subcommand
return cmd.invoke(cmd_ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 659, in invoke
ctx.invoke(self.callback, *_ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 325, in invoke
return callback(_args, **kwargs)
File "/home/fourmax/bench/bench/cli.py", line 97, in start
_start()
File "/home/fourmax/bench/bench/utils.py", line 157, in start
raise Exception("No process manager found")
Exception: No process manager found

Make site available on another port (nginx)

bench set-nginx-port sitename port
bench set-default-site sitename
bench config no_default_site on|off

tasks:
- [ ] allow kwargs to be passed to generate_config

Should add another server block for the site in the nginx config

Installer Error

Hello, running the command bench get-app erpnext https://github.com/frappe/erpnext gives me the following error

Cloning into 'erpnext'...
remote: Counting objects: 1713, done.
remote: Compressing objects: 100% (1408/1408), done.
Receiving objects: 100% (1713/1713), 2.91 MiB | 300.00 KiB/s, done.
remote: Total 1713 (delta 457), reused 642 (delta 203)
Resolving deltas: 100% (457/457), done.
Checking connectivity... done.
Obtaining file:///home/erpnext/frappe-bench/apps/erpnext
Running setup.py (path:/home/erpnext/frappe-bench/apps/erpnext/setup.py) egg_info for package from file:///home/erpnext/frappe-bench/apps/erpnext

warning: no files found matching '*.json'
warning: no previously-included files matching '*.pyc' found under directory '*'

Downloading/unpacking frappe==4.1.0 (from erpnext==4.1.0)
Could not find any downloads that satisfy the requirement frappe==4.1.0 (from erpnext==4.1.0)
Cleaning up...
No distributions at all found for frappe==4.1.0 (from erpnext==4.1.0)
Storing debug log for failure in /home/erpnext/.pip/pip.log
Error: None
Traceback (most recent call last):
File "/usr/local/bin/bench", line 9, in
load_entry_point('bench==0.1', 'console_scripts', 'bench')()
File "/home/erpnext/bench-repo/bench/cli.py", line 26, in cli
return bench()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 488, in call
return self.main(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 474, in main
self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 758, in invoke
return self.invoke_subcommand(ctx, cmd, cmd_name, ctx.args[1:])
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 767, in invoke_subcommand
return cmd.invoke(cmd_ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 659, in invoke
ctx.invoke(self.callback, *_ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 325, in invoke
return callback(_args, **kwargs)
File "/home/erpnext/bench-repo/bench/cli.py", line 58, in get_app
_get_app(name, git_url)
File "/home/erpnext/bench-repo/bench/app.py", line 28, in get_app
install_app(app, bench=bench)
File "/home/erpnext/bench-repo/bench/app.py", line 38, in install_app
exec_cmd("{pip} install -e {app}".format(pip=os.path.join(bench, 'env', 'bin', 'pip'), app=os.path.join(bench, 'apps', app)))
File "/home/erpnext/bench-repo/bench/utils.py", line 56, in exec_cmd
subprocess.check_call(cmd, cwd=cwd, shell=True)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command './env/bin/pip install -e ./apps/erpnext' returned non-zero exit status 1

And here is the pip.log file on Pastebin http://pastebin.com/vL7e479g

GitPython==0.3.2 not available can use GitPython==0.3.2.RC1

Install script fails on Ubuntu 14.04 and Centos 6.5 error is the same:

Downloading/unpacking GitPython==0.3.2 (from bench==0.1)
Could not find a version that satisfies the requirement GitPython==0.3.2 (from bench==0.1) (from versions: 0.1.7, 0.2.0-beta1, 0.3.0-beta1, 0.3.0-beta2, 0.3.1-beta2, 0.3.2.RC1)
Cleaning up...
No distributions matching the version for GitPython==0.3.2 (from bench==0.1)
Storing debug log for failure in /root/.pip/pip.log

Upstream package is: https://pypi.python.org/pypi/GitPython/0.3.2.RC1

bench

Make easy install script

  • Check if Python2.7 is available
  • Install Prerequisites
    • Add MariaDB Repo
    • Install Packages
  • Create user (frappe) if current user is root
  • Clone bench in home dir
  • Install bench in global Python env
  • Setup bench in ~/frappe-bench
  • Configure auto update and backups

Add Configuration

Options:

  • restart_supervisor_on_update
  • update_bench_on_update

(incomplete list)

push-app?

Should we have a helper command, bench push-app frappe to push to "origin" if configured?

use specific site

after install i was adding 3 sites to the erpnext
and i use bench start to run the server for production

how can i use aspecific site

bench start

Use foreman/forego/honcho to start the required process for local development

Fix 3to4 migration script

-from .utils import exec_cmd, get_sites, get_frappe
 import frappe
 import argparse
 import os
 import imp
 import json
 import shutil
+import subprocess
+
+def get_sites(bench='.'):
+       sites_dir = os.path.join(bench, "sites")
+       sites = [site for site in os.listdir(sites_dir) 
+               if os.path.isdir(os.path.join(sites_dir, site)) and site not in ('assets',)]
+       return sites
+
+
+def exec_cmd(cmd, cwd='.'):
+       try:
+               subprocess.check_call(cmd, cwd=cwd, shell=True)
+       except subprocess.CalledProcessError, e:
+               print "Error:", e.output
+               raise
+
+def get_frappe(bench='.'):
+       frappe = os.path.abspath(os.path.join(bench, 'env', 'bin', 'frappe'))
+       if not os.path.exists(frappe):
+               print 'frappe app is not installed. Run the following command to install frappe'
+               print 'bench get-app frappe https://github.com/frappe/frappe.git'
+       return frappe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.