0

I have a django app for which i am using celery tasks to perform some csv processing in background, and so i installed rabbitmq-server like sudo apt-get install rabbitmq-server, by this command the rabbitmq-server was installed and running successfully.

And i have some celery tasks code in tasks.py module inside an app and running the celery like below

celery -A app.tasks worker --loglevel=info

which was working fine and executing the csv files in background successfully, but now i just want to daemonize the above command, and i searched about any option to daemonize it but i din't found any arguments to pass like -D to daemonize the above command. So is there anyway that i can daemonize the above command and make celery run ?

AlvaroAV
  • 10,335
  • 12
  • 60
  • 91
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313

2 Answers2

0

I think you're looking for the --detach option. [1]

But is recommended that you use something like systemd. The celery docs has a whole page on this topic. [2]

[1] http://celery.readthedocs.org/en/latest/reference/celery.bin.base.html#daemon-options

[2] http://celery.readthedocs.org/en/latest/tutorials/daemonizing.html

Fedalto
  • 1,507
  • 1
  • 10
  • 13
0

supervisorctl will be a better bet on this.

Installation: sudo apt-get install supervisor

The main configuration file of supervisor is here: /etc/supervisor/supervisord.conf

Run $vim /etc/supervisor/supervisord.conf to inspect. Looking into the file, at the bottom, youu'll notice:

[include]
files = /etc/supervisor/conf.d/*.conf

This basically means that config files of your projects can be stored here /etc/supervisor/conf.d/ and they will be automatically included.

Run: sudo vim /etc/supervisor/conf.d/myapp.conf. Your configuration may look like:

[program:myapp]
command={{ your celery commands without curly braces }}
directory=/directory/to/myapp
autostart=true
autorestart=true
stderr_logfile=/var/log/myapp.err.log
stdout_logfile=/var/log/myapp.out.log

To Restart service: $sudo service supervisor restart

To Re-read after making updates to any *.conf file: $sudo supervisorctl reread

To record updates: $sudo supervisorctl update

To check status of specific *.conf: sudo supervisorctl status myapp

Check your log files for more status data.

Olamigoke Philip
  • 1,035
  • 8
  • 10