Skip to content

Commit

Permalink
Merge branch 'master' into 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mher committed Jul 1, 2022
2 parents ad3a68e + 9829f05 commit cc3f131
Show file tree
Hide file tree
Showing 34 changed files with 176 additions and 172 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
python-version: 3.9

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Set up python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:alpine

# Get latest root certificates
RUN apk add --no-cache ca-certificates && update-ca-certificates
RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates

# Install the required packages
RUN pip install --no-cache-dir redis flower
Expand Down Expand Up @@ -29,4 +29,4 @@ USER flower

VOLUME $FLOWER_DATA_DIR

ENTRYPOINT ["flower"]
CMD ["celery", "flower"]
12 changes: 2 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Core Celery args that you may want to set::
-b, --broker
--result-backend

More info on available `Celery command args <https://docs.celeryproject.org/en/stable/reference/cli.html#celery>`_.
More info on available `Celery command args <https://docs.celeryq.dev/en/stable/reference/cli.html#celery>`_.

For Flower command args `see here <https://flower.readthedocs.io/en/latest/config.html#options>`_.

Expand Down Expand Up @@ -104,8 +104,7 @@ Celery command and before Flower sub-command): ::
API
---

Flower API enables to manage the cluster via REST API, call tasks and
receive task events in real-time via WebSockets.
Flower API enables to manage the cluster via REST API.

For example you can restart worker's pool by: ::

Expand All @@ -119,13 +118,6 @@ Or terminate executing task by: ::

$ curl -X POST -d 'terminate=True' http://localhost:5555/api/task/revoke/8a4da87b-e12b-4547-b89a-e92e4d1f8efd

Or receive task completion events in real-time: ::

var ws = new WebSocket("ws://localhost:5555/api/task/events/task-succeeded/");
ws.onmessage = function (event) {
console.log(event.data);
}

For more info checkout `API Reference`_ and `examples`_.

.. _API Reference: https://flower.readthedocs.io/en/latest/api.html
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- redis
flower:
build: ./
command: python -m flower -A tasks
command: celery -A tasks flower
volumes:
- ./examples:/data
working_dir: /data
Expand All @@ -40,3 +40,6 @@ services:
environment:
CELERY_BROKER_URL: redis://redis
CELERY_RESULT_BACKEND: redis://redis
depends_on:
- worker
- redis
16 changes: 8 additions & 8 deletions docs/api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"metadata": {},
"source": [
"# Tasks API\n",
"The tasks API is *async*, meaning calls will return immediatly and you'll need to poll on task status."
"The tasks API is *async*, meaning calls will return immediately and you'll need to poll on task status."
]
},
{
Expand Down Expand Up @@ -195,7 +195,7 @@
"metadata": {},
"source": [
"## result\n",
"Gets the task result. This is *async* and will return immediatly even if the task didn't finish (with state 'PENDING')"
"Gets the task result. This is *async* and will return immediately even if the task didn't finish (with state 'PENDING')"
]
},
{
Expand Down Expand Up @@ -283,7 +283,7 @@
"metadata": {},
"source": [
"## rate-limit\n",
"Update [rate limit](http://docs.celeryproject.org/en/latest/userguide/tasks.html#Task.rate_limit) for a task."
"Update [rate limit](https://docs.celeryq.dev/en/latest/userguide/tasks.html#Task.rate_limit) for a task."
]
},
{
Expand Down Expand Up @@ -324,7 +324,7 @@
"metadata": {},
"source": [
"## timeout\n",
"Set timeout (both [hard](http://docs.celeryproject.org/en/latest/userguide/tasks.html#Task.time_limit) and [soft](http://docs.celeryproject.org/en/latest/userguide/tasks.html#Task.soft_time_limit)) for a task."
"Set timeout (both [hard](https://docs.celeryq.dev/en/latest/userguide/tasks.html#Task.time_limit) and [soft](https://docs.celeryq.dev/en/latest/userguide/tasks.html#Task.soft_time_limit)) for a task."
]
},
{
Expand Down Expand Up @@ -470,7 +470,7 @@
"metadata": {},
"source": [
"## pool/restart\n",
"Restart a worker pool, you need to have [CELERYD_POOL_RESTARTS](http://docs.celeryproject.org/en/latest/configuration.html#std:setting-CELERYD_POOL_RESTARTS) enabled in your configuration)."
"Restart a worker pool, you need to have [CELERYD_POOL_RESTARTS](https://docs.celeryq.dev/en/latest/configuration.html#std:setting-CELERYD_POOL_RESTARTS) enabled in your configuration)."
]
},
{
Expand Down Expand Up @@ -591,7 +591,7 @@
"metadata": {},
"source": [
"## pool/autoscale\n",
"[Autoscale](http://docs.celeryproject.org/en/latest/userguide/workers.html#autoscaling) a pool."
"[Autoscale](https://docs.celeryq.dev/en/latest/userguide/workers.html#autoscaling) a pool."
]
},
{
Expand Down Expand Up @@ -631,7 +631,7 @@
"metadata": {},
"source": [
"## queue/add-consumer\n",
"[Add a consumer](http://docs.celeryproject.org/en/latest/userguide/workers.html#std:control-add_consumer) to a queue."
"[Add a consumer](https://docs.celeryq.dev/en/latest/userguide/workers.html#std:control-add_consumer) to a queue."
]
},
{
Expand Down Expand Up @@ -672,7 +672,7 @@
"metadata": {},
"source": [
"## queue/cancel-consumer\n",
"[Cancel a consumer](http://docs.celeryproject.org/en/latest/userguide/workers.html#queues-cancelling-consumers) queue."
"[Cancel a consumer](https://docs.celeryq.dev/en/latest/userguide/workers.html#queues-cancelling-consumers) queue."
]
},
{
Expand Down
5 changes: 5 additions & 0 deletions docs/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Protecting your Flower instance from unwarranted access is important
if it runs in an untrusted environment. Below, we outline the various
forms of authentication supported by Flower.

**NOTE:** The following endpoints are exempt from authentication:

- /healthcheck
- /metrics

.. _basic-auth:

HTTP Basic Authentication
Expand Down
20 changes: 19 additions & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Standard Celery configuration settings can be overridden in the configuration
file. See `Celery Configuration reference`_ for a complete listing of all
the available settings, and their default values.

.. _`Celery Configuration reference`: http://docs.celeryproject.org/en/latest/userguide/configuration.html
.. _`Celery Configuration reference`: https://docs.celeryq.dev/en/latest/userguide/configuration.html

Celery command line options also can be passed to Flower. For example
the `--broker` sets the default broker URL: ::
Expand Down Expand Up @@ -316,3 +316,21 @@ purge_offline_workers
Time (in seconds) after which offline workers are automatically removed from dashboard.

If omitted, offline workers remain on the dashboard.

.. _task_runtime_metric_buckets:

task_runtime_metric_buckets
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sets task runtime latency buckets

buckets value can be provided as cli options: ::

$ celery flower --task_runtime_metric_buckets=1,5,10,inf

Or, it can be also provided as ENV variable: ::

$ export FLOWER_TASK_RUNTIME_METRIC_BUCKETS=1,5,10,inf

If not provided:
- default prometheus buckets will be used
2 changes: 1 addition & 1 deletion docs/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ official Redis image.

$ docker run --name localredis -p 6379:6379 --rm -d redis

Now, clone this repository, build flower from the Dockerfile, start the
Now, clone this repository (https://github.com/mher/flower), build flower from the Dockerfile, start the
container and open http://localhost:49555 ::

$ docker build -t "flower" .
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Flower - Celery monitoring tool

Flower is a web based tool for monitoring and administrating `Celery`_ clusters

.. _Celery: https://docs.celeryproject.org/en/stable/#
.. _Celery: https://docs.celeryq.dev/en/stable/#

.. include:: features.rst

Expand Down
4 changes: 2 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Core Celery args that you may want to set::
-b, --broker
--result-backend

More info on available `Celery command args <https://docs.celeryproject.org/en/stable/reference/cli.html#celery>`_.
More info on available `Celery command args <https://docs.celeryq.dev/en/stable/reference/cli.html#celery>`_.

For Flower command args `see here <https://flower.readthedocs.io/en/latest/config.html#options>`_.

Expand All @@ -41,7 +41,7 @@ Launch the Flower server at specified port other than default 5555 (open the UI

Specify Celery application path with address and port for Flower: ::

$ celery -A proj flower --address=127.0.0.6 --port=5566
$ celery -A proj flower --address=127.0.0.6 --port=5566

Launch using docker: ::

Expand Down
1 change: 1 addition & 0 deletions docs/man.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ OPTIONS
--url_prefix base url prefix
--xheaders enable support for the 'X-Real-Ip' and
'X-Scheme' headers. (default *False*)
--task_runtime_metric_buckets task runtime prometheus latency metric buckets (default prometheus latency buckets)

TORNADO OPTIONS
===============
Expand Down
4 changes: 2 additions & 2 deletions docs/prometheus-integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ We have the following labels available:

* **task** - task name, i.e. ``tasks.add``, ``tasks.multiply``.
* **type** - task event type, i.e. ``task-started``, ``task-succeeded``. Note that worker related events **will not be counted**.
For more info on task event types see: `task events in celery <https://docs.celeryproject.org/en/stable/userguide/monitoring.html#task-events>`_.
For more info on task event types see: `task events in celery <https://docs.celeryq.dev/en/stable/userguide/monitoring.html#task-events>`_.
* **worker** - celery worker name, i.e ``celery@<your computer name>``.

Example Prometheus Alerts
Expand Down Expand Up @@ -144,7 +144,7 @@ Start Flower Monitoring

In your Celery application folder run this command (Flower needs to be installed)::

celery flower -A tasks --broker=redis://localhost:6379/0
celery -A tasks --broker=redis://localhost:6379/0 flower

Configure and Start Prometheus
------------------------------
Expand Down
20 changes: 0 additions & 20 deletions examples/event-api.html

This file was deleted.

30 changes: 6 additions & 24 deletions flower/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
import tornado.websocket
import tornado.web
from ..views import BaseHandler


class BaseWebSocketHandler(tornado.websocket.WebSocketHandler):
# listeners = [], should be created in derived class

def open(self):
listeners = self.listeners
listeners.append(self)

def on_message(self, message):
pass

def on_close(self):
listeners = self.listeners
if self in listeners:
listeners.remove(self)

@classmethod
def send_message(cls, message):
for l in cls.listeners:
l.write_message(message)

def check_origin(self, origin):
return True
class BaseApiHandler(BaseHandler):
def prepare(self):
if self.application.options.basic_auth or self.application.options.auth:
raise tornado.web.HTTPError(405, "api is not available when auth is enabled")
4 changes: 2 additions & 2 deletions flower/api/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from tornado import gen
from tornado import util

from ..views import BaseHandler
from . import BaseApiHandler


logger = logging.getLogger(__name__)


class ControlHandler(BaseHandler):
class ControlHandler(BaseApiHandler):
def is_worker(self, workername):
return workername and workername in self.application.workers

Expand Down
35 changes: 0 additions & 35 deletions flower/api/events.py

This file was deleted.

4 changes: 2 additions & 2 deletions flower/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from celery.backends.base import DisabledBackend

from ..utils import tasks
from ..views import BaseHandler
from . import BaseApiHandler
from ..utils.broker import Broker
from ..api.control import ControlHandler
from collections import OrderedDict
Expand All @@ -24,7 +24,7 @@
logger = logging.getLogger(__name__)


class BaseTaskHandler(BaseHandler):
class BaseTaskHandler(BaseApiHandler):
DATE_FORMAT = '%Y-%m-%d %H:%M:%S.%f'

def get_task_args(self):
Expand Down
10 changes: 8 additions & 2 deletions flower/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ def is_flower_envvar(name):

def print_banner(app, ssl):
if not options.unix_socket:
if options.url_prefix:
prefix_str = f'/{options.url_prefix}/'
else:
prefix_str = ''

logger.info(
"Visit me at http%s://%s:%s", 's' if ssl else '',
options.address or 'localhost', options.port
"Visit me at http%s://%s:%s%s", 's' if ssl else '',
options.address or 'localhost', options.port,
prefix_str
)
else:
logger.info("Visit me via unix socket file: %s", options.unix_socket)
Expand Down

0 comments on commit cc3f131

Please sign in to comment.