【问题标题】:Celery: running a worker with superuser privilegesCelery:运行具有超级用户权限的工作人员
【发布时间】:2014-08-26 17:00:39
【问题描述】:

我已经使用 runit 作为用户而不是 root 启动了一个 celery 进程。当我查看 svlogd 日志时,我看到:

2014-07-05_10:07:44.10586 Running a worker with superuser privileges when the
2014-07-05_10:07:44.10589 worker accepts messages serialized with pickle is a very bad idea!
2014-07-05_10:07:44.10589 
2014-07-05_10:07:44.10589 If you really want to continue then you have to set the C_FORCE_ROOT
2014-07-05_10:07:44.10589 environment variable (but please think about this before you do).
2014-07-05_10:07:44.10589 
2014-07-05_10:07:44.10590 User information: uid=0 euid=0 gid=0 egid=0

似乎 celery 以 root 身份运行,但是当我运行 ps aux 时,它实际上是以预期用户身份运行的:

jwes     2046  0.0  1.1 226172 45260 ?        S    19:01   0:00 /home/jwes/.virtualenvs/my-app/bin/python manage.py celeryd -E -l INFO -B
fezah     2047  0.0  1.1 217784 43008 ?        S    19:01   0:00 /home/jwes/.virtualenvs/my-app/bin/python manage.py celeryd -E -l INFO -B

任何人都知道如何解决这个问题

【问题讨论】:

  • 您不会在 ps aux 输出中看到 root worker,因为它会在日志中打印该错误后关闭。

标签: python django celery


【解决方案1】:

使用来自另一个 SO 线程的 answer。我添加了以下设置

app.conf.update(
     CELERY_ACCEPT_CONTENT = ['json'],
     CELERY_TASK_SERIALIZER = 'json',
     CELERY_RESULT_SERIALIZER = 'json', 
)

而且它似乎奏效了。

【讨论】:

    猜你喜欢
    • 2020-01-28
    • 1970-01-01
    • 2021-08-15
    • 2021-09-11
    • 1970-01-01
    • 1970-01-01
    • 2013-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多