如何由超级用户运行芹菜工人? [英] How to run celery workers by superuser?

查看:136
本文介绍了如何由超级用户运行芹菜工人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用sudo运行芹菜工人时,出现以下错误:

When I run celery workers with sudo, i get the following error:

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(Cipater)
操作系统-> Linux(Ubuntu 14.04)

More information:
Python --> 2.7.6
celery --> 3.1.23 (Cipater)
OS --> Linux(Ubuntu 14.04)

我应该如何用sudo运行芹菜?我知道它并不安全,但是出于某些原因,我确实需要这样做!

How should I run celery with sudo? I know it's not secure but for some reasons I really need to do it!

推荐答案

好,我找到了解决方案!
在celery 3.1及更高版本中,具有腌制序列化的工作人员将崩溃,如文档:

OK I found the solution!
In celery 3.1 and above, workers with pickle serialization will crash as mentioned in documentation:

如果现在以启用了pickle的root用户身份运行,Worker将崩溃.

Worker will now crash if running as the root user with pickle enabled.

因此要使用sudo,您需要在celery配置中禁用pickle序列化.我使用json做到了这一点:

So to use sudo, you need to disable pickle serialization in celery configs.I did it by using json:

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

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

and then if you run using sudo, it will work!

这篇关于如何由超级用户运行芹菜工人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆