
1 neoblackcap 2015-11-26 11:21:02 +08:00 那,你为什么不试试自己用 supervisor 去管理你的 celery 守护进程啊。我没试过系统自带的。 supervisor 倒是可以配置多个守护进程。 同时为什么要隔离呢?不是只要 worker 能执行就好了吗?按道理你只要将你的 task 注册了就好了 |
2 lixia625 OP @neoblackcap 我也是这么想的,但目前只有一个 app 的 task 能被执行,是我 celeryd 的姿势不对么? |
3 neoblackcap 2015-11-26 11:37:47 +08:00 @lixia625 我觉得是你的 celery 配置没设置好,你的 task 没有注册,你倒是发一下 log 啊 |
4 lixia625 OP @neoblackcap # Names of nodes to start # most will only start one node CELERY_NODES="worker" # but you can also start multiple and configure settings # for each in CELERYD_OPTS (see 'celery multi --help' for example) #CELERY_NODES="worker1 worker2 worker3" # Absolute or relative path to the 'celery' command CELERY_BIN="/usr/local/bin/celery" # CELERY_BIN="/virtualenvs/def/bin/celery" # App instance to use # comment out this line if you don't use an app CELERY_APP="app1" # or fully qualified: #CELERY_APP="proj.tasks:app" # Where to chdir at start CELERYD_CHDIR="/var/www/app1/" # Extra command-line arguments to the worker CELERY_OPTS="--time-limit=1800 --cOncurrency=8" # %N will be replaced with the first pat of the nodename. CELERYD_LOG_FILE="/var/log/celery/%N.log" CELERYD_PID_FILE="/var/run/celery/%N.pid" ... 这样的话 app1 是完全正常的,但也只有 /var/www/app1/的任务被执行, log 里也只有 app1 的 log 啊 我现在的问题就是我还有一个 /var/www/app2/我该怎么弄 T_T |
5 neoblackcap 2015-11-26 12:01:32 +08:00 你这个配置文档是在哪里的?/etc/celeryd? 你用 django 的,我真的建议你用 supervisor 去一起管理你的应用,具体请参考[document]( http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html?highlight=celery_app) |
6 neoblackcap 2015-11-26 12:03:12 +08:00 @lixia625 你只注册 app1 那肯定只会跑 app1 啊,还有就是你用什么版本的 celery 啊? |
7 xunyu 2015-11-26 12:25:08 +08:00 |
8 julyclyde 2015-11-26 13:37:15 +08:00 不要总是建议别人怎么办 还要说出这种建议的理由 上面几位我觉得自己可能都不懂 celery 的配置吧 |
9 lixia625 OP @neoblackcap @xunyu @julyclyde 在 /etc/init.d/celeryd 中,发现这样一段话 # To implement separate init scripts, copy this script and give it a different # name: # I.e., if my new application, "little-worker" needs an init, I # should just use: # # cp /etc/init.d/celeryd /etc/init.d/little-worker # # You can then configure this by manipulating /etc/default/little-worker. # 于是我照着做了,创建了另一个脚本,启动进程,然后两个网站的任务都能被接收到并执行了。 另外我也试了用 supervisor ,也达到了同样的效果。 然而。。。 事情是这样的,这实际上是两个相同的网站,只不过连了不同的数据库,所以在我以为搞定了的时候,发现两者的任务混在了一起,也就是 app1 中触发的任务,一会儿改动的是 app1 连的数据库,一会儿改动的是 app2 连的数据库 这又是什么情况,用的是 rabbitmq ,看现象大概是它无法区分两个 app 发来的任务? 正确的做法应该是什么? route ? queue ?还是多个 rabbitmq host ? |
10 julyclyde 2015-11-26 17:38:27 +08:00 You can then configure this by manipulating /etc/default/little-worker 这一步做了吗? |
11 julyclyde 2015-11-26 17:38:50 +08:00 不同任务应该用不同的队列吧。你在 rabbitmq 里新增一个 queue 呗 |
12 neoblackcap 2015-11-26 18:04:12 +08:00 |
13 111111111111 2016-01-13 12:07:17 +08:00 @neoblackcap 老司机,请教一下 不同应用是可以使用同一个队列的的吗? 那么各应用在更新了代码之后,怎么用重启 celery 呢? 生产环境怎么安排比较好呢 @lixia625 lz 问题搞定了吗?最近遇到同样问题 |