Commit 9e24bd1b authored by sim's avatar sim

[DOC] Celery, RabbitMQ and uWSGI dependencies

parent fa9027aa
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
## TL;DR ## TL;DR
Gargantext main backend is written in Python 3.5. For a basic setup you need Gargantext main backend is written in Python 3.5. For a basic setup you need
`pipenv`, an up-to-date version of `pip`, a PostgreSQL (>= 9.5) database and an up-to-date version of `pip`, `pipenv`, a PostgreSQL (>= 9.5) database,
[PostgREST](https://postgrest.com/). RabbitMQ (default message broker for asynchronous tasks) and
[PostgREST](https://postgrest.com/). See below for more details.
To setup development environment, run django test server and postgrest: To setup a development environment and run backend servers in DEBUG mode:
git clone -b gargantext-light ssh://git@gitlab.iscpif.fr:20022/humanities/gargantext.git gargantext-light git clone -b gargantext-light ssh://git@gitlab.iscpif.fr:20022/humanities/gargantext.git gargantext-light
cd gargantext-light cd gargantext-light
...@@ -16,25 +17,32 @@ To setup development environment, run django test server and postgrest: ...@@ -16,25 +17,32 @@ To setup development environment, run django test server and postgrest:
By default Django test server is running at <http://localhost:8000>, and By default Django test server is running at <http://localhost:8000>, and
PostgREST at <http://localhost:3000>. PostgREST at <http://localhost:3000>.
Web server `uWSGI` is needed for production, behind any good enough HTTP
server, for example `nginx`.
## Requirements ## Requirements
External dependencies are listed below. Python ones are automatically handled
by `pipenv` and are mainly Django, Celery, SQLAlchemy and Alembic. See
`./Pipfile` for details about used versions.
### Up-to-date pip ### Up-to-date pip
On Debian-like distros, `pip` is not installed by default, if you didn't do it On Debian-like distros, `pip` is not installed by default, if you didn't do it
already: already:
sudo apt install python3-pip sudo apt-get install python3-pip
Pipenv (see below) needs an up-to-date version of pip, on a Debian-like just Pipenv (see below) needs an up-to-date version of pip, on a Debian-like just
`apt upgrade`, otherwise upgrade it like so: `apt-get upgrade`, otherwise upgrade it like so:
pip install pip --user --upgrade pip install pip --user --upgrade
### Pipenv ### Pipenv
You will need [pipenv][1] to easily get dependencies of Gargantext. You will need [pipenv][1] to easily get dependencies of Gargantext. It handles
It handles packages and takes care of the virtualenv and environment variables. python packages and takes care of the virtualenv and environment variables.
There are various ways to install `pipenv`, see its [documentation][2] for more There are various ways to install `pipenv`, see its [documentation][2] for more
insights. Here is the straightforward way: insights. Here is the straightforward way:
...@@ -44,11 +52,10 @@ insights. Here is the straightforward way: ...@@ -44,11 +52,10 @@ insights. Here is the straightforward way:
[1]: https://github.com/kennethreitz/pipenv [1]: https://github.com/kennethreitz/pipenv
[2]: https://docs.pipenv.org/ [2]: https://docs.pipenv.org/
### PostgreSQL ### PostgreSQL
Gargantext rely on PostgreSQL (>= 9.5) for data persistence. To install it Gargantext rely on [PostgreSQL](https://www.postgresql.org/) (>= 9.5) for data
on a Debian-based OS: persistence. To install it on a Debian-based OS:
sudo apt-get install postgresql-9.6 postgresql-client-9.6 sudo apt-get install postgresql-9.6 postgresql-client-9.6
...@@ -57,11 +64,44 @@ To setup Gargantext database: ...@@ -57,11 +64,44 @@ To setup Gargantext database:
sudo -u postgres psql -c "CREATE USER gargantua PASSWORD '<pass>' CREATEROLE BYPASSRLS" sudo -u postgres psql -c "CREATE USER gargantua PASSWORD '<pass>' CREATEROLE BYPASSRLS"
sudo -u postgres createdb -O gargantua gargandb sudo -u postgres createdb -O gargantua gargandb
### Celery
[Celery](http://www.celeryproject.org/) is used to handle asynchronous tasks,
its installation is handled by `pipenv` so you don't need to take care of it,
just note that version 3.1 is used because `djcelery` is used for django admin
integration.
Celery 3.1 documentation: <http://docs.celeryproject.org/en/3.1/>
### RabbitMQ
[RabbitMQ](http://www.rabbitmq.com/) is the default[^2] message broker of
Celery, version 3.6 is enough. Installations instructions here:
<https://www.rabbitmq.com/download.html>.
To install it on Debian:
sudo apt-get install rabbitmq-server
[^2]: It it is possible to use another broker, but RabbitMQ is the only one
supported out of the box, plus it is really simple to deploy. See
<http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html>.
### PostgREST ### PostgREST
See <https://postgrest.com/en/v4.1/tutorials/tut0.html#step-3-install-postgrest> See <https://postgrest.com/en/v4.1/tutorials/tut0.html#step-3-install-postgrest>
for installation instructions. for installation instructions.
### uWSGI
[uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/) is the web server used by
Gargantext in production. It is supposed to run behind an HTTP server such as
nginx.
To install it on Debian:
sudo apt-get install uwsgi
## Installation ## Installation
...@@ -75,8 +115,8 @@ Or for production (without dev dependencies and without `DEBUG` mode): ...@@ -75,8 +115,8 @@ Or for production (without dev dependencies and without `DEBUG` mode):
make ENVIR=prod setup make ENVIR=prod setup
If you want to specify custom paths for configuration files (by default If you want to specify custom paths for configuration files (by default
`gargantext.ini` and `postgrest.conf` in current directory), use `GARGANTEXT_CONF` `gargantext.ini` and `postgrest.conf` in current directory), use
and `POSTGREST_CONF` environment variable. For example: `GARGANTEXT_CONF` and `POSTGREST_CONF` environment variable. For example:
GARGANTEXT_CONF=/etc/gargantext/gargantext.ini \ GARGANTEXT_CONF=/etc/gargantext/gargantext.ini \
POSTGREST_CONF=/etc/gargantext/postgrest.conf make ENVIR=prod setup POSTGREST_CONF=/etc/gargantext/postgrest.conf make ENVIR=prod setup
...@@ -141,11 +181,14 @@ about how these options are used. ...@@ -141,11 +181,14 @@ about how these options are used.
generate JSON Web Tokens, so it MUST be reflected in PostgREST configuration generate JSON Web Tokens, so it MUST be reflected in PostgREST configuration
* `ALLOWED_HOSTS`: space separated list of allowed hosts * `ALLOWED_HOSTS`: space separated list of allowed hosts
* `TIME_ZONE`: see <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> * `TIME_ZONE`: see <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
* `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASS`: pretty obvious... * `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASS`: database settings
* `LOG_FILE`: log file path * `LOG_FILE`: django backend log file path
* `LOG_LEVEL`: `DEBUG` | `INFO` | `WARNING` | `ERROR` | `CRITICAL` * `LOG_LEVEL`: `DEBUG` | `INFO` | `WARNING` | `ERROR` | `CRITICAL`
* `LOG_FORMATTER`: `simple` | `verbose`, formatters can be added in settings.py * `LOG_FORMATTER`: `simple` | `verbose`, formatters can be added in settings.py
* `TESTSERVER_PIDFILE`: pidfile for the testserver (only used by startup script) * `TESTSERVER_PIDFILE`: pidfile for the testserver (only used by startup script)
* `CELERYD_PID_FILE`: pidfile for celery main worker
* `CELERYD_LOG_FILE`: celery log file path
* `CELERYD_LOG_LEVEL`: `DEBUG` | `INFO` | `WARNING` | `ERROR` | `CRITICAL`
[^1]: Details here: <https://stackoverflow.com/questions/15170637/effects-of-changing-djangos-secret-key#answer-15383766>. [^1]: Details here: <https://stackoverflow.com/questions/15170637/effects-of-changing-djangos-secret-key#answer-15383766>.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment