Skip to content

Commit

Permalink
Merge pull request #195 from frappe/new-install
Browse files Browse the repository at this point in the history
Bench v2.0
  • Loading branch information
anandpdoshi committed Mar 23, 2016
2 parents 8278ff9 + 11d73bf commit 486a584
Show file tree
Hide file tree
Showing 110 changed files with 3,125 additions and 1,175 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: python
dist: trusty
sudo: required

python:
- "2.7"

install:
- sudo apt-get purge -y mysql-common mysql-server mysql-client
# - sudo python $TRAVIS_BUILD_DIR/installer/install.py --user travis --skip-bench-setup
- sudo bash $TRAVIS_BUILD_DIR/install_scripts/setup_frappe.sh --skip-install-bench --mysql-root-password travis
- mkdir -p ~/bench-repo
- cp -r $TRAVIS_BUILD_DIR/* ~/bench-repo/
# - cd ~ && sudo python bench-repo/installer/install.py --only-dependencies

script:
- cd ~
- sudo pip install --upgrade pip
- sudo pip install -e bench-repo
# - sudo python -m unittest bench.tests.test_setup_production.TestSetupProduction.test_new_site
- sudo python -m unittest -v bench.tests.test_setup_production
78 changes: 53 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ The bench allows you to setup Frappe / ERPNext apps on your local Linux (CentOS

To do this install, you must have basic information on how Linux works and should be able to use the command-line. If you are looking easier ways to get started and evaluate ERPNext, [download the Virtual Machine or take a free trial on ERPNext.com](https://erpnext.com/pricing).

For questions, please join the [developer forum](https://discuss.frappe.io/).
If you have questions, please ask them on our [forum](https://discuss.erpnext.com/).

Installation
============

Easy way
--------

Supported for CentOS 6, CentOS 7, Debian 7 and Ubuntu 12.04+
Easy Production Setup
---------------------
> For production use and which also installs ERPNext. Supported for CentOS 6, CentOS 7, Debian 7 and Ubuntu 12.04+
> This is an opinionated setup with logging and SE Linux. So, it is best to setup on a blank server.
Open your Terminal and enter:

Expand All @@ -22,11 +22,40 @@ wget https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup
sudo bash setup_frappe.sh --setup-production
```

This script should install the pre-requisites, install bench and setup an ERPNext site. This will setup ERPNext with nginx, with Supervisor enabled and checkout the master branch of the ERPNext repo. Passwords for Frappe, Frappe Administrator and MariaDB (root) will be generated. You can then login as Administrator with the Administrator password printed.
- This script will install the pre-requisites, install bench and setup an ERPNext site
- This will setup ERPNext with nginx, with Supervisor enabled and checkout the master branch of the ERPNext repo
- Passwords for Frappe, Frappe Administrator and MariaDB (root) will be generated
- You can then login as **Administrator** with the Administrator password printed

If you want to develop ERPNext or any Frappe App, you can omit the "--setup-production" part from the command. This will setup ERPNext as well. Use ```bench start``` to run the server.

Note: If you are using a DigitalOcean droplet or any other cloud provider's vps, make sure it has >= 1gb of ram or has swap setup properly.
> Note: If you are using a DigitalOcean droplet or any other cloud provider's vps, make sure it has >= 1gb of ram or has swap setup properly.
Development Setup (Beta)
------------------------

Tested on Ubuntu 14.04+ and MacOS X. If you find any problems, post them on our forum: [https://discuss.erpnext.com](https://discuss.erpnext.com)

```
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
python install.py
```

This script requires Python2.7+ installed on your machine. You need to run this with a user that is **not** `root`, but can `sudo`. If you don't have such a user, you can search the web for *How to add a new user in { your OS }* and *How to add an existing user to sudoers in { your OS }*.

This script will:

- Install pre-requisites like git and ansible
- Shallow clones this bench repository under `/usr/local/frappe/bench-repo`
- Runs the Ansible playbook 'playbooks/develop/install.yml', which:
- Installs
- MariaDB and its config
- Redis
- NodeJS
- WKHTMLtoPDF with patched QT
- Initializes a new Bench at `~/frappe/frappe-bench` with `frappe` framework already installed under `apps`.

You will have to manually create a new site (`bench new-site`) and get apps that you need (`bench get-app`, `bench install-app`).

Manual Install
--------------
Expand All @@ -36,7 +65,7 @@ Install pre-requisites,
* [Python 2.7](https://www.python.org/download/releases/2.7/)
* [MariaDB](https://mariadb.org/)
* [Redis](http://redis.io/topics/quickstart)
* [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html) (optional, required for pdf generation)
* [WKHTMLtoPDF with patched QT](http://wkhtmltopdf.org/downloads.html) (required for pdf generation)

[Installing pre-requisites on OSX](https://github.com/frappe/bench/wiki/Installing-Bench-Pre-requisites-on-MacOSX)

Expand All @@ -47,6 +76,9 @@ Install bench as a *non root* user,

Note: Please do not remove the bench directory the above commands will create

Initialize Bench using: `bench init frappe-bench`. Here you can replace `frappe-bench` with a name of your choice for your bench.


Installing ERPNext
------------------

Expand Down Expand Up @@ -75,9 +107,11 @@ Basic Usage
* Add apps

The get-app command gets and installs frappe apps. Examples include
[erpnext](https://github.com/frappe/erpnext) and
[shopping-cart](https://github.com/frappe/shopping-cart)


- [erpnext](https://github.com/frappe/erpnext)
- [erpnext_shopify](https://github.com/frappe/erpnext_shopify)
- [paypal_integration](https://github.com/frappe/paypal_integration)

bench get-app erpnext https://github.com/frappe/erpnext

* Add site
Expand Down Expand Up @@ -118,12 +152,6 @@ You can now either use `bench start` or setup the bench for production use.
Updating
========

On initializing a new bench, a cronjob is added to automatically update the bench
at 1000hrs (as per the time on your machine). You can disable this by running
`bench config auto_update off` and run `bench config auto_update on` to switch
it on again. To change the time of update, you will have to edit the cronjob
manually using `crontab -e`.

To manually update the bench, run `bench update` to update all the apps, run
patches, build JS and CSS files and restart supervisor (if configured to).

Expand Down Expand Up @@ -152,7 +180,7 @@ External services
-----------------

* MariaDB (Datastore for frappe)
* Redis (Broker for frappe background workers)
* Redis (Queue for frappe background workers and caching)
* nginx (for production deployment)
* supervisor (for production deployment)

Expand Down Expand Up @@ -183,10 +211,10 @@ Production Deployment
=====================


You can setup the bench for production use by configuring two programs
, Supervisor and nginx. These steps are automated if you pass
`--setup-production` to the easy install script or run `sudo bench
setup production`
You can setup the bench for production use by configuring two programs, Supervisor and nginx.

> These steps are automated if you pass `--setup-production` to the easy install script
> or run `sudo bench setup production`
Supervisor
----------
Expand All @@ -202,13 +230,13 @@ eg,

```
bench setup supervisor
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe.conf
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf
```

Note: 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.ini #for CentOS 7 only
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.ini #for CentOS 7 only
```

The bench will also need to restart the processes managed by supervisor when you
Expand All @@ -228,7 +256,7 @@ eg,

```
bench setup nginx
sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe.conf
sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf
```

Note: When you restart nginx after the configuration change, it might fail if
Expand Down
5 changes: 5 additions & 0 deletions bench/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from jinja2 import Environment, PackageLoader

__version__ = "2.0.0"

env = Environment(loader=PackageLoader('bench.config'), trim_blocks=True)
10 changes: 6 additions & 4 deletions bench/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from .utils import exec_cmd, get_frappe, check_git_for_shallow_clone, get_config, build_assets, restart_supervisor_processes, get_cmd_output, run_frappe_cmd
from .utils import (exec_cmd, get_frappe, check_git_for_shallow_clone, build_assets,
restart_supervisor_processes, get_cmd_output, run_frappe_cmd)
from .config.common_site_config import get_config

import logging
import requests
Expand Down Expand Up @@ -42,7 +44,7 @@ def write_appstxt(apps, bench='.'):

def get_app(app, git_url, branch=None, bench='.', build_asset_files=True, verbose=False):
logger.info('getting app {}'.format(app))
shallow_clone = '--depth 1' if check_git_for_shallow_clone() and get_config().get('shallow_clone') else ''
shallow_clone = '--depth 1' if check_git_for_shallow_clone() else ''
branch = '--branch {branch}'.format(branch=branch) if branch else ''
exec_cmd("git clone {git_url} {branch} {shallow_clone} --origin upstream {app}".format(
git_url=git_url,
Expand All @@ -54,7 +56,7 @@ def get_app(app, git_url, branch=None, bench='.', build_asset_files=True, verbos
install_app(app, bench=bench, verbose=verbose)
if build_asset_files:
build_assets(bench=bench)
conf = get_config()
conf = get_config(bench=bench)
if conf.get('restart_supervisor_on_update'):
restart_supervisor_processes(bench=bench)

Expand All @@ -81,7 +83,7 @@ def install_app(app, bench='.', verbose=False):
add_to_appstxt(app, bench=bench)

def pull_all_apps(bench='.'):
rebase = '--rebase' if get_config().get('rebase_on_pull') else ''
rebase = '--rebase' if get_config(bench).get('rebase_on_pull') else ''

for app in get_apps(bench=bench):
app_dir = get_repo_dir(app, bench=bench)
Expand Down
Loading

0 comments on commit 486a584

Please sign in to comment.