6

I have python server based on django and celery. Each time computer restarts, apache2 starts so my server is working, BUT I have to restart celery manually (going to my project directory and executing "python manage.py celeryd"). What is the correct solution for production? I mean, is there a possibility to start celery as daemon?

Here http://github.com/ask/celery/tree/master/contrib/debian/init.d/ I found two scripts which looks like they should be in /etc/init.d/ like apache2 script that starts apache2. But I put them to /etc/init.d/ and as I see nothing changes.

3 Answers3

4

You could manually symlink the /etc/init.d scripts from /etc/rc5.d/, to start when your GUI does. And you'd need another for shutdown.

But Debian has a more advanced (and better) method. This controls what gets linked from the individual runlevels init scripts. That's what the "BEGIN INIT INFO" is used for in the comments section at the top of those scripts.

If you're actually using Debian, instead of just using scripts from one of their resources, try using

update-rc.d celerybeat defaults
update-rc.d celeryd defaults
Christopher Karel
  • 6,442
  • 1
  • 26
  • 34
  • Yes, that's it. Nice solution, works excellent to me! Just don't forget to make scripts executable! –  Mar 02 '10 at 18:25
  • Should the `update-rc.d ... enable` command also be run as described here? http://askubuntu.com/questions/388434/celeryd-not-running-at-startup – raacer Dec 26 '14 at 22:17
  • 1
    I'll readily admit I'm not a huge Debian guy, but I don't think so. I believe the defaults command should also enable the script at the runlevels listed in the script header. The enable argument only seems useful to undo the effects of the disable argument. (See: The 'disabling init scripts' of the man page: http://manpages.ubuntu.com/manpages/utopic/man8/update-rc.d.8.html) – Christopher Karel Dec 31 '14 at 16:10
1

Celery ships a sample configuration for supervisor, a daemon which takes care of project related tasks and daemons. Debian Unstable already has a packaged version of supervisor available. If you install it you would only need to modify the sample configuration from celery (found in contrib/supervisor) and drop it into /etc/supervisor/conf.d/.

Fladi
  • 850
  • 4
  • 7
0

You didn't mention which distro you're using. That's important to know because startup scripts vary quite a bit from distro to distro. Assuming you're working with Redhat/CentOS...

Ideally you should track down an init.d script. This is the better option because it's also used to safely shutdown your daemon, reload it's config, restart it, etc. If you want the quick and easy solution though, just stick "python manage.py celeryd" at the end of you /etc/rc.local file.

Edit: I see by the path name in your example that you're using Debian. I'm not sure if Debian has an /etc/rc.local file. But I'll leave this answer up just in case it does, or in case this information is useful to someone else.

jamieb
  • 3,387
  • 4
  • 24
  • 36