How to run celery workers by superuser?

淺唱寂寞╮ 提交于 2019-12-02 03:19:11

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

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

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',
)

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!