mirror of
https://github.com/frappe/bench.git
synced 2024-11-14 09:14:04 +00:00
Merge branch 'develop' into develop_adam_reinstall
This commit is contained in:
commit
2c6faa2b47
31
README.md
31
README.md
@ -18,6 +18,7 @@ Bench is a command-line utility that helps you to install, update, and manage mu
|
|||||||
- [Bench Manager](#bench-manager)
|
- [Bench Manager](#bench-manager)
|
||||||
- [Guides](#guides)
|
- [Guides](#guides)
|
||||||
- [Resources](#resources)
|
- [Resources](#resources)
|
||||||
|
- [Development](#development)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
|
|
||||||
@ -254,6 +255,36 @@ For an exhaustive list of guides, check out [Bench Guides](https://frappe.io/doc
|
|||||||
For an exhaustive list of resources, check out [Bench Resources](https://frappe.io/docs/user/en/bench/resources).
|
For an exhaustive list of resources, check out [Bench Resources](https://frappe.io/docs/user/en/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`
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ 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.
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# 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.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This repository has been released under the [GNU GPLv3 License](LICENSE).
|
This repository has been released under the [GNU GPLv3 License](LICENSE).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
VERSION = "5.1.0"
|
VERSION = "5.2.1"
|
||||||
PROJECT_NAME = "frappe-bench"
|
PROJECT_NAME = "frappe-bench"
|
||||||
FRAPPE_VERSION = None
|
FRAPPE_VERSION = None
|
||||||
|
|
||||||
|
10
bench/cli.py
10
bench/cli.py
@ -18,6 +18,7 @@ from bench.utils import PatchError, bench_cache_file, check_latest_version, drop
|
|||||||
|
|
||||||
from_command_line = False
|
from_command_line = False
|
||||||
change_uid_msg = "You should not run this command as root"
|
change_uid_msg = "You should not run this command as root"
|
||||||
|
src = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
def cli():
|
def cli():
|
||||||
@ -26,12 +27,15 @@ def cli():
|
|||||||
command = " ".join(sys.argv)
|
command = " ".join(sys.argv)
|
||||||
|
|
||||||
change_working_directory()
|
change_working_directory()
|
||||||
logger = setup_logging() or logging.getLogger(bench.PROJECT_NAME)
|
logger = setup_logging()
|
||||||
logger.info(command)
|
logger.info(command)
|
||||||
|
|
||||||
|
if sys.argv[1] not in ("src", ):
|
||||||
check_uid()
|
check_uid()
|
||||||
change_dir()
|
|
||||||
change_uid()
|
change_uid()
|
||||||
|
|
||||||
|
change_dir()
|
||||||
|
|
||||||
if is_dist_editable(bench.PROJECT_NAME) and len(sys.argv) > 1 and sys.argv[1] != "src" and not get_config(".").get("developer_mode"):
|
if is_dist_editable(bench.PROJECT_NAME) and len(sys.argv) > 1 and sys.argv[1] != "src" and not get_config(".").get("developer_mode"):
|
||||||
log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3)
|
log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3)
|
||||||
|
|
||||||
@ -72,7 +76,7 @@ def check_uid():
|
|||||||
|
|
||||||
|
|
||||||
def cmd_requires_root():
|
def cmd_requires_root():
|
||||||
if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'supervisor', 'lets-encrypt', 'fonts',
|
if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt', 'fonts',
|
||||||
'print', 'firewall', 'ssh-port', 'role', 'fail2ban', 'wildcard-ssl'):
|
'print', 'firewall', 'ssh-port', 'role', 'fail2ban', 'wildcard-ssl'):
|
||||||
return True
|
return True
|
||||||
if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production'):
|
if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production'):
|
||||||
|
@ -111,7 +111,7 @@ def download_translations():
|
|||||||
download_translations_p()
|
download_translations_p()
|
||||||
|
|
||||||
|
|
||||||
@click.command('renew-lets-encrypt', help="Renew Let's Encrypt certificate")
|
@click.command('renew-lets-encrypt', help="Sets Up latest cron and Renew Let's Encrypt certificate")
|
||||||
def renew_lets_encrypt():
|
def renew_lets_encrypt():
|
||||||
from bench.config.lets_encrypt import renew_certs
|
from bench.config.lets_encrypt import renew_certs
|
||||||
renew_certs()
|
renew_certs()
|
||||||
@ -164,8 +164,8 @@ def disable_production():
|
|||||||
|
|
||||||
@click.command('src', help="Prints bench source folder path, which can be used as: cd `bench src`")
|
@click.command('src', help="Prints bench source folder path, which can be used as: cd `bench src`")
|
||||||
def bench_src():
|
def bench_src():
|
||||||
import bench
|
from bench.cli import src
|
||||||
print(os.path.dirname(bench.__path__[0]))
|
print(os.path.dirname(src))
|
||||||
|
|
||||||
|
|
||||||
@click.command('find', help="Finds benches recursively from location")
|
@click.command('find', help="Finds benches recursively from location")
|
||||||
|
@ -87,10 +87,16 @@ def run_certbot_and_setup_ssl(site, custom_domain, bench_path, interactive=True)
|
|||||||
|
|
||||||
def setup_crontab():
|
def setup_crontab():
|
||||||
job_command = '/opt/certbot-auto renew -a nginx --post-hook "systemctl reload nginx"'
|
job_command = '/opt/certbot-auto renew -a nginx --post-hook "systemctl reload nginx"'
|
||||||
|
job_comment = 'Renew lets-encrypt every month'
|
||||||
|
print("Setting Up cron job to {0}".format(job_comment))
|
||||||
|
|
||||||
system_crontab = CronTab(user='root')
|
system_crontab = CronTab(user='root')
|
||||||
if job_command not in str(system_crontab):
|
|
||||||
job = system_crontab.new(command=job_command, comment="Renew lets-encrypt every month")
|
for job in system_crontab.find_comment(comment=job_comment): # Removes older entries
|
||||||
job.day.on(1)
|
system_crontab.remove(job)
|
||||||
|
|
||||||
|
job = system_crontab.new(command=job_command, comment=job_comment)
|
||||||
|
job.setall('0 0 */1 * *') # Run at 00:00 every day-of-month
|
||||||
system_crontab.write()
|
system_crontab.write()
|
||||||
|
|
||||||
|
|
||||||
@ -113,10 +119,13 @@ def get_certbot_path():
|
|||||||
|
|
||||||
|
|
||||||
def renew_certs():
|
def renew_certs():
|
||||||
|
# Needs to be run with sudo
|
||||||
click.confirm('Running this will stop the nginx service temporarily causing your sites to go offline\n'
|
click.confirm('Running this will stop the nginx service temporarily causing your sites to go offline\n'
|
||||||
'Do you want to continue?',
|
'Do you want to continue?',
|
||||||
abort=True)
|
abort=True)
|
||||||
|
|
||||||
|
setup_crontab()
|
||||||
|
|
||||||
service('nginx', 'stop')
|
service('nginx', 'stop')
|
||||||
exec_cmd("{path} renew".format(path=get_certbot_path()))
|
exec_cmd("{path} renew".format(path=get_certbot_path()))
|
||||||
service('nginx', 'start')
|
service('nginx', 'start')
|
||||||
|
@ -443,10 +443,13 @@ def setup_logging(bench_path='.'):
|
|||||||
logging.Logger.log = logv
|
logging.Logger.log = logv
|
||||||
|
|
||||||
if os.path.exists(os.path.join(bench_path, 'logs')):
|
if os.path.exists(os.path.join(bench_path, 'logs')):
|
||||||
logger = logging.getLogger(bench.PROJECT_NAME)
|
|
||||||
log_file = os.path.join(bench_path, 'logs', 'bench.log')
|
log_file = os.path.join(bench_path, 'logs', 'bench.log')
|
||||||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
|
||||||
hdlr = logging.FileHandler(log_file)
|
hdlr = logging.FileHandler(log_file)
|
||||||
|
else:
|
||||||
|
hdlr = logging.NullHandler()
|
||||||
|
|
||||||
|
logger = logging.getLogger(bench.PROJECT_NAME)
|
||||||
|
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
||||||
hdlr.setFormatter(formatter)
|
hdlr.setFormatter(formatter)
|
||||||
logger.addHandler(hdlr)
|
logger.addHandler(hdlr)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
@ -72,7 +72,7 @@ These commands belong directly to the bench group so they can be invoked directl
|
|||||||
|
|
||||||
- **init**: Initialize a new bench instance in the specified path. This sets up a complete bench folder with an `apps` folder which contains all the Frappe apps available in the current bench, `sites` folder that stores all site data seperated by individual site folders, `config` folder that contains your redis, NGINX and supervisor configuration files. The `env` folder consists of all python dependencies the current bench and installed Frappe applications have.
|
- **init**: Initialize a new bench instance in the specified path. This sets up a complete bench folder with an `apps` folder which contains all the Frappe apps available in the current bench, `sites` folder that stores all site data seperated by individual site folders, `config` folder that contains your redis, NGINX and supervisor configuration files. The `env` folder consists of all python dependencies the current bench and installed Frappe applications have.
|
||||||
- **restart**: Restart web, supervisor, systemd processes units. Used in production setup.
|
- **restart**: Restart web, supervisor, systemd processes units. Used in production setup.
|
||||||
- **update**: Updates bench tool and if executed in a bench directory, without any flags will backup, pull, setup requirements, build, run patches and restart bench. Using specific flags will only do certain tasks instead of all.
|
- **update**: If executed in a bench directory, without any flags will backup, pull, setup requirements, build, run patches and restart bench. Using specific flags will only do certain tasks instead of all.
|
||||||
- **migrate-env**: Migrate Virtual Environment to desired Python version. This regenerates the `env` folder with the specified Python version.
|
- **migrate-env**: Migrate Virtual Environment to desired Python version. This regenerates the `env` folder with the specified Python version.
|
||||||
- **retry-upgrade**: Retry a failed upgrade
|
- **retry-upgrade**: Retry a failed upgrade
|
||||||
- **disable-production**: Disables production environment for the bench.
|
- **disable-production**: Disables production environment for the bench.
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
|
|
||||||
* Updating
|
* Updating
|
||||||
|
|
||||||
Currently, `bench update` can be run from any directory however the context of the command changes. If run from a bench directory, the vanilla command itself updates all apps, runs migrations and backs up all sites.
|
To update the bench CLI tool, depending on your method of installation, you may use
|
||||||
|
|
||||||
|
pip3 install -U frappe-bench
|
||||||
|
|
||||||
|
|
||||||
|
To backup, update all apps and sites on your bench, you may use
|
||||||
|
|
||||||
bench update
|
bench update
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ def install_prerequisites():
|
|||||||
install_package('pip3', 'python3-pip')
|
install_package('pip3', 'python3-pip')
|
||||||
|
|
||||||
success = run_os_command({
|
success = run_os_command({
|
||||||
'python3': "sudo -H python3 -m pip install --upgrade setuptools cryptography ansible==2.8.5 pip"
|
'python3': "sudo -H python3 -m pip install --upgrade setuptools wheel cryptography ansible==2.8.5 pip"
|
||||||
})
|
})
|
||||||
|
|
||||||
if not (success or shutil.which('ansible')):
|
if not (success or shutil.which('ansible')):
|
||||||
@ -269,7 +269,7 @@ def install_bench(args):
|
|||||||
|
|
||||||
def clone_bench_repo(args):
|
def clone_bench_repo(args):
|
||||||
'''Clones the bench repository in the user folder'''
|
'''Clones the bench repository in the user folder'''
|
||||||
branch = args.bench_branch or 'master'
|
branch = args.bench_branch or 'develop'
|
||||||
repo_url = args.repo_url or 'https://github.com/frappe/bench'
|
repo_url = args.repo_url or 'https://github.com/frappe/bench'
|
||||||
|
|
||||||
if os.path.exists(tmp_bench_repo):
|
if os.path.exists(tmp_bench_repo):
|
||||||
@ -464,11 +464,11 @@ if __name__ == '__main__':
|
|||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("ignore")
|
warnings.simplefilter("ignore")
|
||||||
setup_log_stream(args)
|
setup_log_stream(args)
|
||||||
|
install_prerequisites()
|
||||||
setup_script_requirements()
|
setup_script_requirements()
|
||||||
check_distribution_compatibility()
|
check_distribution_compatibility()
|
||||||
check_system_package_managers()
|
check_system_package_managers()
|
||||||
check_environment()
|
check_environment()
|
||||||
install_prerequisites()
|
|
||||||
install_bench(args)
|
install_bench(args)
|
||||||
|
|
||||||
log("Bench + Frappe + ERPNext has been successfully installed!")
|
log("Bench + Frappe + ERPNext has been successfully installed!")
|
||||||
|
@ -5,6 +5,6 @@ Jinja2==2.10.3
|
|||||||
python-crontab==2.4.0
|
python-crontab==2.4.0
|
||||||
requests==2.22.0
|
requests==2.22.0
|
||||||
semantic-version==2.8.2
|
semantic-version==2.8.2
|
||||||
setuptools==40.8.0
|
setuptools
|
||||||
six==1.13.0
|
six
|
||||||
virtualenv==16.6.0
|
virtualenv
|
||||||
|
@ -6,7 +6,7 @@ message="
|
|||||||
Please access ERPNext by going to http://localhost:8080 on the host system.
|
Please access ERPNext by going to http://localhost:8080 on the host system.
|
||||||
The username is \"Administrator\" and password is \"admin\"
|
The username is \"Administrator\" and password is \"admin\"
|
||||||
|
|
||||||
Do consider donating at https://frappe.io/buy
|
Consider buying professional support from us at https://erpnext.com/support
|
||||||
|
|
||||||
To update, login as
|
To update, login as
|
||||||
username: frappe
|
username: frappe
|
||||||
|
Loading…
Reference in New Issue
Block a user