tomoya 1 anno fa
commit
497a811dee
3 ha cambiato i file con 58 aggiunte e 0 eliminazioni
  1. 34 0
      README.md
  2. 17 0
      docker-compose.yml
  3. 7 0
      tasks.py

+ 34 - 0
README.md

@@ -0,0 +1,34 @@
+# Distributed Architecture
+
+This includes  
+* Redis
+* Flower
+
+
+## Celery
+### Starting the worker
+```shell
+celery -A proj worker 
+```
+#### Options
+Worker Options:
+  * -n, --hostname HOSTNAME         Set custom hostname (e.g., 'w1@%%h').  
+                                    Expands: %%h (hostname), %%n (name) and %%d, (domain).
+  * -D, --detach                    Start worker as a background process.
+  * -S, --statedb PATH              Path to the state database. The extension
+                                  '.db' may be appended to the filename.
+  * -l, --loglevel [DEBUG|INFO|WARNING|ERROR|CRITICAL|FATAL]
+                                    Logging level.
+  * -O, --optimization [default|fair]
+                                    Apply optimization profile.
+  * --prefetch-multiplier <prefetch multiplier>
+                                    Set custom prefetch multiplier value for
+                                    this worker instance.
+Pool Options:
+  * -c, --concurrency <concurrency>
+                                    Number of child processes processing the  
+                                    queue.  The default is the number of CPUs  
+                                    available on your system.  
+``` celery worker --help ``` can get more infomation.  
+### woker in Windows
+add ``` --pool=solo ``` option 

+ 17 - 0
docker-compose.yml

@@ -0,0 +1,17 @@
+version: "3.3"
+services:
+  queue:
+    image: redis:7
+    ports:
+      - 6379:6379
+
+  flower:
+    image: mher/flower:latest
+    ports:
+      - 5555:5555
+    environment:
+      CELERY_BROKER_URL: redis://queue
+      CELERY_RESULT_BACKEND: redis://queue
+    #command: 
+    depends_on:
+      - queue

+ 7 - 0
tasks.py

@@ -0,0 +1,7 @@
+from celery import Celery
+
+app = Celery('tasks', backend ='redis://172.104.92.245', broker='redis://172.104.92.245')
+
+@app.task
+def hello():
+    return 'hello world'