Browse Source

Add DJANGO_PROJECT_DIR environment variable to celeryd (it's appended to
sys.path)

Ask Solem 16 years ago
parent
commit
742f9bad6c
2 changed files with 9 additions and 4 deletions
  1. 4 1
      celery/bin/celeryd
  2. 5 3
      contrib/debian/init.d/celeryd

+ 4 - 1
celery/bin/celeryd

@@ -1,7 +1,10 @@
 #!/usr/bin/env python
 import os
 import sys
-sys.path.append(os.getcwd())
+django_project_dir = os.environ.get("DJANGO_PROJECT_DIR")
+if django_project_dir:
+    sys.path.append(django_project_dir)
+
 from django.conf import settings
 from celery.platform import PIDFile, daemonize, remove_pidfile
 from celery.log import setup_logger

+ 5 - 3
contrib/debian/init.d/celeryd

@@ -20,6 +20,7 @@ CELERYD_LOG_LEVEL="INFO"
 CELERYD="celeryd"
 
 export DJANGO_SETTINGS_MODULE
+export DJANGO_PROJECT_DIR
 
 # /etc/init.d/ssh: start and stop the celery task worker daemon.
 
@@ -30,7 +31,7 @@ fi
 
 . /lib/lsb/init-functions
 
-chdir $DJANGO_PROJECT_DIR
+cd $DJANGO_PROJECT_DIR
 
 CELERYD_OPTS="-f $CELERYD_LOG_FILE -l $CELERYD_LOG_LEVEL -p \
                     $CELERYD_PID_FILE -d"
@@ -60,8 +61,9 @@ check_dev_null() {
 
 export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
 if [ ! -n "$VIRTUALENV" ]; then
-    . "$VIRTUALENV/current/bin/activate"
-    export PATH="$VIRTUALENV/current/bin:$PATH"
+    . "$VIRTUALENV/bin/activate"
+    export PATH="$VIRTUALENV/bin:$PATH"
+    CELERYD="$VIRTUALENV/bin/$CELERYD"
 fi