【问题标题】:How to run celery workers by superuser?如何通过超级用户运行芹菜工人?
【发布时间】:2016-09-19 11:44:56
【问题描述】:

当我使用 sudo 运行 celery worker 时,出现以下错误:

Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!

If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).

User information: uid=0 euid=0 gid=0 egid=0

我的 C_FORCE_ROOT 环境变量也是 true

echo $C_FORCE_ROOT
true

更多信息:
Python --> 2.7.6
芹菜 --> 3.1.23 (Cipter)
操作系统 --> Linux(Ubuntu 14.04)

我应该如何使用 sudo 运行 celery?我知道它不安全,但出于某些原因我真的需要这样做!

【问题讨论】:

    标签: python linux celery


    【解决方案1】:

    好的,我找到了解决方案!
    在 celery 3.1 及更高版本中,带有 pickle 序列化的工人将崩溃,如documentation 所述:

    如果在启用 pickle 的情况下以 root 用户身份运行,Worker 现在会崩溃。

    所以要使用 sudo,你需要在 celery configs 中禁用 pickle 序列化。我是使用 json 做到的:

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

    然后,如果您使用 sudo 运行,它将起作用!

    【讨论】:

      猜你喜欢
      • 2022-10-25
      • 2021-10-24
      • 1970-01-01
      • 2020-10-07
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      相关资源
      最近更新 更多