From 05323edc80a7b3515db77c2145adeddd61cff885 Mon Sep 17 00:00:00 2001 From: Lucas Simon Date: Wed, 14 Nov 2018 22:03:55 -0200 Subject: [PATCH 1/2] Improve docs --- docs/index.rst | 71 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index ff1a301..ebb96a7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -202,9 +202,56 @@ Commands ~~~~~~~~ There isn't an official overview of CLI commands in the RQ documentation, -but these are the commands that Flask-RQ2 support. +but these are the commands that Flask-RQ2 support:: + + export FLASK_APP='app.py' + + +Setup the `cli.py` + + +.. code-block:: python + + from .rq import rq + + def register(app): + rq.init_cli(app) + + # anothers cli commands... + @app.cli.command() + @click.argument('name') + def create_user(name): + '''This commands create an user''' + print('create') + + +In your `app.py` call the create factory above + + +.. code-block:: python + + #... + + # Apps + from apps import create_app, cli + + # ... + app = create_app(getenv('FLASK_ENV')) + cli.register(app) + + if __name__ == '__main__': + app.run(host=ip, debug=debug, port=port, use_reloader=debug) + + +Then show the helps:: + + flask rq + + +- ``worker`` -- Starts an `RQ worker`_ (required to run jobs):: + + flask run worker -- ``worker`` -- Starts an `RQ worker`_ (required to run jobs). - ``scheduler`` -- Starts an `RQ Scheduler`_ (optional for scheduled jobs). @@ -212,7 +259,23 @@ but these are the commands that Flask-RQ2 support. - ``empty`` -- Empty the given `RQ queues`_. -- ``requeue`` -- Requeues `failed jobs`_. +- ``requeue`` -- Requeues `failed jobs`_ + +Parameters:: + + --all or -a Requeue all failed jobs + + +Run the command to execute all jobs:: + + $ flask rq requeue --all + Requeueing 1 jobs from failed queue + + +Or you can run a list of job ids:: + + $ flask rq requeue bb43879f-b0e2-4bf0-b6c5-4debf925180e cba947e8-5a95-45a5-b63d-2857799006e8 + - ``suspend`` -- Suspends all workers. @@ -255,7 +318,7 @@ The default queues that the worker and CLI commands (``empty``, ``info`` and .. code-block:: python - app.config['RQ_QUEUES'] = ['default'] + app.config['RQ_QUEUES'] = ['default', 'failed'] ``RQ_ASYNC`` ~~~~~~~~~~~~ From d9b3f288692033e559c80095a6c335c940dad95a Mon Sep 17 00:00:00 2001 From: Lucas Simon Date: Sun, 18 Nov 2018 22:07:49 -0200 Subject: [PATCH 2/2] Setup Flake8 to ignore W605 --- setup.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.cfg b/setup.cfg index cf4e2a4..40e76f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,7 @@ test = pytest [bdist_wheel] universal = 1 + +[flake8] +ignore = W605 +exclude = docs/*