Skip to content

Instantly share code, notes, and snippets.

@lamby
Created April 2, 2011 22:43
Show Gist options
  • Save lamby/899978 to your computer and use it in GitHub Desktop.
Save lamby/899978 to your computer and use it in GitHub Desktop.
diff --git a/djcelery/management/commands/celeryd.py b/djcelery/management/commands/celeryd.py
index cffadf7..3270de3 100644
--- a/djcelery/management/commands/celeryd.py
+++ b/djcelery/management/commands/celeryd.py
@@ -4,10 +4,13 @@ Start the celery daemon from the Django management command.
"""
from celery.bin import celeryd
+from celery.bin.base import Option
from djcelery.app import app
from djcelery.management.base import CeleryCommand
+from django.utils.daemonize import become_daemon
+
worker = celeryd.WorkerCommand(app=app)
@@ -15,7 +18,11 @@ class Command(CeleryCommand):
"""Run the celery daemon."""
help = 'Runs a Celery worker node.'
requires_model_validation = True
- option_list = CeleryCommand.option_list + worker.get_options()
+ option_list = CeleryCommand.option_list + worker.get_options() + (
+ Option("--daemonize", action="store_true", default=False),
+ )
def handle(self, *args, **options):
+ if options['daemonize']:
+ become_daemon()
worker.run(*args, **options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment