From e61341df79187f41e7ac13244468b1a5cf3c39e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=BF=E5=AE=8F=E4=BC=9F?= Date: Wed, 31 Aug 2016 16:33:05 +0800 Subject: [PATCH] Update README.md to README.rst --- apps/common/{README.md => README.rst} | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) rename apps/common/{README.md => README.rst} (55%) diff --git a/apps/common/README.md b/apps/common/README.rst similarity index 55% rename from apps/common/README.md rename to apps/common/README.rst index f7c0a641b..18a0db578 100644 --- a/apps/common/README.md +++ b/apps/common/README.rst @@ -3,18 +3,18 @@ Jumpserver use celery to run task async. Using redis as the broker, so you should run a redis instance -1. Run redis +* Run redis ``` # yum -y install redis or # docker run -name jumpserver-redis -d -p 6379:6379 redis redis-server ``` +* Write tasks in app_name/tasks.py -2. Write tasks in app_name/tasks.py - -ops/tasks.py ``` +ops/tasks.py + from __future__ import absolute_import import time @@ -30,17 +30,26 @@ def longtime_add(x, y): return x + y ``` -3. Run celery in development +* Run celery in development ``` # cd apps # celery -A common worker -l info ``` -4. Test using task +* Test using task ``` # ./manage.py shell -> from ops.tasks import longtime_add -> res = longtime_add.delay(1, 2) -> res.get() +>>> from ops.tasks import longtime_add +>>> res = longtime_add.delay(1, 2) +>>> res.get() ``` +### celery usage of jumpserver +Jumpserver use celery to run task async. Using redis as the broker, so you should run a redis instance, Let’s start it + +**Run redis server ** +'' $ yum -y install redis +'' or +'' $ docker run -name jumpserver-redis -d -p 6379:6379 redis redis-server + +** \ No newline at end of file