You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bench_usage.md 9.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # bench CLI Usage
  2. This may not be known to a lot of people but half the bench commands we're used to, exist in the Xhive Framework and not in bench directly. Those commands generally are the `--site` commands. This page is concerned only with the commands in the bench project. Any framework commands won't be a part of this consolidation.
  3. # bench CLI Commands
  4. Under Click's structure, `bench` is the main command group, under which there are three main groups of commands in bench currently, namely
  5. - **install**: The install command group deals with commands used to install system dependencies for setting up Xhive environment
  6. - **setup**: This command group for consists of commands used to maipulate the requirements and environments required by your Xhive environment
  7. - **config**: The config command group deals with making changes in the current bench (not the CLI tool) configuration
  8. ## Using the bench command line
  9. ```zsh
  10. ➜ bench
  11. Usage: bench [OPTIONS] COMMAND [ARGS]...
  12. Bench manager for Xhive
  13. Options:
  14. --version
  15. --help Show this message and exit.
  16. Commands:
  17. backup Backup single site
  18. backup-all-sites Backup all sites in current bench
  19. config Change bench configuration
  20. disable-production Disables production environment for the bench.
  21. download-translations Download latest translations
  22. exclude-app Exclude app from updating
  23. find Finds benches recursively from location
  24. get-app Clone an app from the internet or filesystem and...
  25. ```
  26. Similarly, all available flags and options can be checked for commands individually by executing them with the `--help` flag. The `init` command for instance:
  27. ```zsh
  28. ➜ bench init --help
  29. Usage: bench init [OPTIONS] PATH
  30. Initialize a new bench instance in the specified path
  31. Options:
  32. --python TEXT Path to Python Executable.
  33. --ignore-exist Ignore if Bench instance exists.
  34. --apps_path TEXT path to json files with apps to install
  35. after init
  36. ```
  37. ## bench and sudo
  38. Some bench commands may require sudo, such as some `setup` commands and everything else under the `install` commands group. For these commands, you may not be asked for your root password if sudoers setup has been done. The security implications, well we'll talk about those soon.
  39. ## General Commands
  40. These commands belong directly to the bench group so they can be invoked directly prefixing each with `bench` in your shell. Therefore, the usage for these commands is as
  41. ```zsh
  42. bench COMMAND [ARGS]...
  43. ```
  44. ### The usual commands
  45. - **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 Xhive 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 Xhive applications have.
  46. - **restart**: Restart web, supervisor, systemd processes units. Used in production setup.
  47. - **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.
  48. - **migrate-env**: Migrate Virtual Environment to desired Python version. This regenerates the `env` folder with the specified Python version.
  49. - **retry-upgrade**: Retry a failed upgrade
  50. - **disable-production**: Disables production environment for the bench.
  51. - **renew-lets-encrypt**: Renew Let's Encrypt certificate for site SSL.
  52. - **backup**: Backup single site data. Can be used to backup files as well.
  53. - **backup-all-sites**: Backup all sites in current bench.
  54. - **get-app**: Download an app from the internet or filesystem and set it up in your bench. This clones the git repo of the Xhive project and installs it in the bench environment.
  55. - **remove-app**: Completely remove app from bench and re-build assets if not installed on any site.
  56. - **exclude-app**: Exclude app from updating during a `bench update`
  57. - **include-app**: Include app for updating. All Xhive applications are included by default when installed.
  58. - **remote-set-url**: Set app remote url
  59. - **remote-reset-url**: Reset app remote url to xhiveframework official
  60. - **remote-urls**: Show apps remote url
  61. - **switch-to-branch**: Switch all apps to specified branch, or specify apps separated by space
  62. - **switch-to-develop**: Switch Xhive and XhiveERP to develop branch
  63. ### A little advanced
  64. - **set-nginx-port**: Set NGINX port for site
  65. - **set-ssl-certificate**: Set SSL certificate path for site
  66. - **set-ssl-key**: Set SSL certificate private key path for site
  67. - **set-url-root**: Set URL root for site
  68. - **set-mariadb-host**: Set MariaDB host for bench
  69. - **set-redis-cache-host**: Set Redis cache host for bench
  70. - **set-redis-queue-host**: Set Redis queue host for bench
  71. - **set-redis-socketio-host**: Set Redis socketio host for bench
  72. - **use**: Set default site for bench
  73. - **download-translations**: Download latest translations
  74. ### Developer's commands
  75. - **start**: Start Xhive development processes. Uses the Procfile to start the Xhive development environment.
  76. - **src**: Prints bench source folder path, which can be used to cd into the bench installation repository by `cd $(bench src)`.
  77. - **find**: Finds benches recursively from location or specified path.
  78. - **pip**: Use the current bench's pip to manage Python packages. For help about pip usage: `bench pip help [COMMAND]` or `bench pip [COMMAND] -h`.
  79. - **new-app**: Create a new Xhive application under apps folder.
  80. ### Release bench
  81. - **release**: Create a release of a Xhive application
  82. - **prepare-beta-release**: Prepare major beta release from develop branch
  83. ## Setup commands
  84. The setup commands used for setting up the Xhive environment in context of the current bench need to be executed using `bench setup` as the prefix. So, the general usage of these commands is as
  85. ```zsh
  86. bench setup COMMAND [ARGS]...
  87. ```
  88. - **sudoers**: Add commands to sudoers list for allowing bench commands execution without root password
  89. - **env**: Setup Python virtual environment for bench. This sets up a `env` folder under the root of the bench directory.
  90. - **redis**: Generates configuration for Redis
  91. - **fonts**: Add Xhive fonts to system
  92. - **config**: Generate or over-write sites/common_site_config.json
  93. - **backups**: Add cronjob for bench backups
  94. - **socketio**: Setup node dependencies for socketio server
  95. - **requirements**: Setup Python and Node dependencies
  96. - **manager**: Setup `bench-manager.local` site with the [Bench Manager](https://github.com/xhiveframework/bench_manager) app, a GUI for bench installed on it.
  97. - **procfile**: Generate Procfile for bench start
  98. - **production**: Setup Xhive production environment for specific user. This installs ansible, NGINX, supervisor, fail2ban and generates the respective configuration files.
  99. - **nginx**: Generate configuration files for NGINX
  100. - **fail2ban**: Setup fail2ban, an intrusion prevention software framework that protects computer servers from brute-force attacks
  101. - **systemd**: Generate configuration for systemd
  102. - **firewall**: Setup firewall for system
  103. - **ssh-port**: Set SSH Port for system
  104. - **reload-nginx**: Checks NGINX config file and reloads service
  105. - **supervisor**: Generate configuration for supervisor
  106. - **lets-encrypt**: Setup lets-encrypt SSL for site
  107. - **wildcard-ssl**: Setup wildcard SSL certificate for multi-tenant bench
  108. - **add-domain**: Add a custom domain to a particular site
  109. - **remove-domain**: Remove custom domain from a site
  110. - **sync-domains**: Check if there is a change in domains. If yes, updates the domains list.
  111. - **role**: Install dependencies via ansible roles
  112. ## Config commands
  113. The config group commands are used for manipulating configurations in the current bench context. The usage for these commands is as
  114. ```zsh
  115. bench config COMMAND [ARGS]...
  116. ```
  117. - **set-common-config**: Set value in common config
  118. - **remove-common-config**: Remove specific keys from current bench's common config
  119. - **update_bench_on_update**: Enable/Disable bench updates on running bench update
  120. - **restart_supervisor_on_update**: Enable/Disable auto restart of supervisor processes
  121. - **restart_systemd_on_update**: Enable/Disable auto restart of systemd units
  122. - **dns_multitenant**: Enable/Disable bench multitenancy on running bench update
  123. - **serve_default_site**: Configure nginx to serve the default site on port 80
  124. - **http_timeout**: Set HTTP timeout
  125. ## Install commands
  126. The install group commands are used for manipulating system level dependencies. The usage for these commands is as
  127. ```zsh
  128. bench install COMMAND [ARGS]...
  129. ```
  130. - **prerequisites**: Installs pre-requisite libraries, essential tools like b2zip, htop, screen, vim, x11-fonts, python libs, cups and Redis
  131. - **nodejs**: Installs Node.js v8
  132. - **nginx**: Installs NGINX. If user is specified, sudoers is setup for that user
  133. - **packer**: Installs Oracle virtualbox and packer 1.2.1
  134. - **psutil**: Installs psutil via pip
  135. - **mariadb**: Install and setup MariaDB of specified version and root password
  136. - **wkhtmltopdf**: Installs wkhtmltopdf v0.12.3 for linux
  137. - **supervisor**: Installs supervisor. If user is specified, sudoers is setup for that user
  138. - **fail2ban**: Install fail2ban, an intrusion prevention software framework that protects computer servers from brute-force attacks
  139. - **virtualbox**: Installs supervisor