How to run celery workers by superuser?

前端 未结 1 1295
栀梦
栀梦 2021-01-22 08:42

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 pickl         


        
相关标签:
1条回答
  • 2021-01-22 09:13

    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!

    0 讨论(0)
提交回复
热议问题