Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Celery as root

Tags:

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?

like image 872
ATOzTOA Avatar asked Dec 03 '13 09:12

ATOzTOA


People also ask

How do you run celery as a service?

Use systemctl enable celery. service if you want the celery service to automatically start when (re)booting the system. Optionally you can specify extra dependencies for the celery service: e.g. if you use RabbitMQ as a broker, you could specify rabbitmq-server.

How do I run celery with my boss?

Run supervisord -c /etc/supervisor/my_proj_name-supervisord. conf to start the supervisord which will start celery workers for your tasks. To stop your supervisord process, run unlink /tmp/supervisor.


2 Answers

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 :) !!

like image 95
securecurve Avatar answered Sep 18 '22 08:09

securecurve


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)
like image 30
Chemical Programmer Avatar answered Sep 20 '22 08:09

Chemical Programmer