From 86afc317f434fd10516e61ffbde7e06089fbfa98 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 26 Aug 2022 11:40:13 +0900 Subject: [PATCH] Describe how to setup flower --- docker/.env.example | 6 ++++-- docs/developer_guide.md | 1 + docs/install_and_upgrade_doccano.md | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index a02aa927..7d441024 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -3,7 +3,6 @@ ADMIN_USERNAME=admin ADMIN_PASSWORD=password ADMIN_EMAIL=admin@example.com - # rabbit mq settings RABBITMQ_DEFAULT_USER=doccano RABBITMQ_DEFAULT_PASS=doccano @@ -11,4 +10,7 @@ RABBITMQ_DEFAULT_PASS=doccano # database settings POSTGRES_USER=doccano POSTGRES_PASSWORD=doccano -POSTGRES_DB=doccano \ No newline at end of file +POSTGRES_DB=doccano + +# Flower settings +FLOWER_BASIC_AUTH="" diff --git a/docs/developer_guide.md b/docs/developer_guide.md index f12c8a85..7260f420 100644 --- a/docs/developer_guide.md +++ b/docs/developer_guide.md @@ -79,6 +79,7 @@ The `tools` directory contains some shell scripts. They are mainly used in Docke | create-package.sh | This script creates doccano's Python package. Note that yarn and poetry must already be installed. | | heroku.sh | This script is used to create django's superuser in Heroku. | | prod-celery.sh | This script is used to run celery in `docker-compose.prod.yml`. | +| prod-flower.sh | This script is used to run Flower in `docker-compose.prod.yml`. | | prod-django.sh | This script is used to run gunicorn in `docker-compose.prod.yml`. In addition, create roles, superuser, and migrate. | | run.sh | This script is used in `Dockerfile`. After creating roles and superuser, run gunicorn and celery. | diff --git a/docs/install_and_upgrade_doccano.md b/docs/install_and_upgrade_doccano.md index 5a3a3cb5..0fe841bb 100644 --- a/docs/install_and_upgrade_doccano.md +++ b/docs/install_and_upgrade_doccano.md @@ -9,8 +9,10 @@ Install doccano on local or in the cloud. Choose the installation method that wo - [Install with pip](#install-with-pip) - [Use PostgreSQL as a database](#use-postgresql-as-a-database) - [Use RabbitMQ as a message broker](#use-rabbitmq-as-a-message-broker) + - [Use Flower to monitor Celery tasks](#use-flower-to-monitor-celery-tasks) - [Install with Docker](#install-with-docker) - [Build a local image with Docker](#build-a-local-image-with-docker) + - [Use Flower](#use-flower) - [Install with Docker Compose](#install-with-docker-compose) - [Install from source](#install-from-source) - [Backend](#backend) @@ -123,6 +125,14 @@ export CELERY_BROKER_URL='amqp://doccano_rabit:doccano_pass@localhost:5672//' That's it. Now you can start webserver and task queue by running the `doccano webserver` and `doccano task` command. Notice that the both commands needs `DATABASE_URL` and `CELERY_BROKER_URL` environment variables if you would change them. +### Use Flower to monitor Celery tasks + +If you want to monitor and manage celery tasks, you can use [Flower](https://flower.readthedocs.io/en/latest/index.html). The `–basic_auth` option accepts _user:password_ pairs separated by a comma. If configured, any client trying to access this Flower instance will be prompted to provide the credentials specified in this argument: + +```bash +doccano flower --basic_auth=user1:password1,user2:password2 +``` + ## Install with Docker doccano is also available as a [Docker](https://www.docker.com/) container. Make sure you have Docker installed on your machine. @@ -156,6 +166,20 @@ If you want to build a local image, run: docker build -t doccano:latest . -f docker/Dockerfile ``` +### Use Flower + +Set `FLOWER_BASIC_AUTH` environment variable and open `5555` port. The variable accepts _user:password_ pairs separated by a comma. + +```bash +docker container create --name doccano \ + -e "ADMIN_USERNAME=admin" \ + -e "ADMIN_EMAIL=admin@example.com" \ + -e "ADMIN_PASSWORD=password" \ + -e "FLOWER_BASIC_AUTH=username:password" + -v doccano-db:/data \ + -p 8000:8000 -p 5555:5555 doccano/doccano +``` + ## Install with Docker Compose You need to install Git and to clone the repository: