Running Celery as root

喜你入骨 提交于 2019-12-03 05:06:22

问题


I need to run my Django along with Celery as root for access reasons. It says I need to set C_FORCE_ROOT environment variable. How/where do I set the environment variable?


回答1:


You can set it to true like this:

# export C_FORCE_ROOT="true"

Then make sure it is set as an env. variable

# echo $C_FORCE_ROOT
true

But make sure to make it permanent, as this will vanish with the next restart

Have fun :) !!




回答2:


1st solution - Manually type command at terminal

$ export C_FORCE_ROOT='true'

2nd solution - Edit shell configuration

$ vi ~/.bashrc

    # add following line
    export C_FORCE_ROOT='true'

$ source ~/.bashrc

3rd solution - Edit manage.py of Django

import os 

if __name__ == '__main__':
    os.environ.setdefault('C_FORCE_ROOT', 'true')
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{PATH TO SETTINGS FILE}')

    execute_from_command_line(sys.argv)



回答3:


Anywhere so the python process picks it up by using os.environ.

If your question is about how the environment variables work, please read this tutorial.



来源:https://stackoverflow.com/questions/20346851/running-celery-as-root

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