2015-03-23 12 views
8

में डेमरीज़ सेलरीबीट मैं लोचदार बीनस्टॉक में एक डेमॉन के रूप में सेलेरीबीट चलाने की कोशिश कर रहा हूं। यहां मेरी कॉन्फ़िगरेशन फ़ाइल है:लोचदार बीनस्टॉक (एडब्ल्यूएस)

files: 
"/opt/python/log/django.log": 
mode: "000666" 
owner: ec2-user 
group: ec2-user 
content: | 
    # Log file 
encoding: plain 
"/opt/elasticbeanstalk/hooks/appdeploy/post/run_supervised_celeryd.sh": 
mode: "000755" 
owner: root 
group: root 
content: | 
    #!/usr/bin/env bash 
    # Get django environment variables 
    celeryenv=`cat /opt/python/current/env | tr '\n' ',' | sed 's/%/%%/g' | sed 's/export //g' | sed 's/$PATH/%(ENV_PATH)s/g' | sed 's/$PYTHONPATH//g' | sed 's/$LD_LIBRARY_PATH//g'` 
    celeryenv=${celeryenv%?} 

    # Create celery configuraiton script 
    celeryconf="[program:celeryd] 
    ; Set full path to celery program if using virtualenv 
    command=/opt/python/run/venv/bin/celery worker -A avtotest --loglevel=INFO 

    directory=/opt/python/current/app 
    user=nobody 
    numprocs=1 
    stdout_logfile=/var/log/celery-worker.log 
    stderr_logfile=/var/log/celery-worker.log 
    autostart=true 
    autorestart=true 
    startsecs=10 

    ; Need to wait for currently executing tasks to finish at shutdown. 
    ; Increase this if you have very long running tasks. 
    stopwaitsecs = 600 

    ; When resorting to send SIGKILL to the program to terminate it 
    ; send SIGKILL to its whole process group instead, 
    ; taking care of its children as well. 
    killasgroup=true 

    ; if rabbitmq is supervised, set its priority higher 
    ; so it starts first 
    priority=998 

    environment=$celeryenv" 

    # Create celerybeat configuraiton script 
    celerybeatconf="[program:celerybeat] 
    ; Set full path to celery program if using virtualenv 
    command=/opt/python/run/venv/bin/celery beat -A avtotest --loglevel=INFO 

    ; remove the -A avtotest argument if you are not using an app instance 

    directory=/opt/python/current/app 
    user=nobody 
    numprocs=1 
    stdout_logfile=/var/log/celerybeat.log 
    stderr_logfile=/var/log/celerybeat.log 
    autostart=true 
    autorestart=true 
    startsecs=10 

    ; Need to wait for currently executing tasks to finish at shutdown. 
    ; Increase this if you have very long running tasks. 
    stopwaitsecs = 600 

    ; When resorting to send SIGKILL to the program to terminate it 
    ; send SIGKILL to its whole process group instead, 
    ; taking care of its children as well. 
    killasgroup=true 

    ; if rabbitmq is supervised, set its priority higher 
    ; so it starts first 
    priority=999 

    environment=$celeryenv" 

    # Create the celery and beat supervisord conf script 
    echo "$celeryconf" | tee /opt/python/etc/celery.conf 
    echo "$celerybeatconf" | tee /opt/python/etc/celerybeat.conf 

    # Add configuration script to supervisord conf (if not there already) 
    if ! grep -Fxq "[include]" /opt/python/etc/supervisord.conf 
     then 
     echo "[include]" | tee -a /opt/python/etc/supervisord.conf 
     echo "files: celery.conf" | tee -a /opt/python/etc/supervisord.conf 
     echo "files: celerybeat.conf" | tee -a /opt/python/etc/supervisord.conf 
    fi 

    # Reread the supervisord config 
    supervisorctl -c /opt/python/etc/supervisord.conf reread 

    # Update supervisord in cache without restarting all services 
    supervisorctl -c /opt/python/etc/supervisord.conf update 

    # Start/Restart celeryd through supervisord 
    supervisorctl -c /opt/python/etc/supervisord.conf restart celeryd 

यह फ़ाइल दोनों अजवाइन और अजवाइन की नींव रखती है। अजवाइन ठीक काम कर रहा है। लेकिन अजवाइन नहीं है। मुझे celerybeat.log फ़ाइल नहीं मिली है जो मुझे लगता है कि मुझे लगता है कि सेलेरीबीट काम नहीं कर रहा है।

इस बारे में कोई विचार?

यदि आवश्यक हो तो मैं अधिक कोड पोस्ट करूंगा। मदद के लिए धन्यवाद

+1

क्या आपको स्क्रिप्ट की आखिरी पंक्ति में 'सेलेरीबीट' को फिर से शुरू करना चाहिए? – pztrick

उत्तर

3

आपका पर्यवेक्षक वाक्यविन्यास थोड़ा सा है, सबसे पहले आपको अपने उदाहरण में एसएसएच की आवश्यकता हो सकती है, और supervisord.conf फ़ाइल को सीधे संपादित कर सकते हैं (vim /opt/python/etc/supervisord.conf), और सीधे इस लाइन को ठीक करें।

echo "[include]" | tee -a /opt/python/etc/supervisord.conf 
echo "files: celery.conf" | tee -a /opt/python/etc/supervisord.conf 
echo "files: celerybeat.conf" | tee -a /opt/python/etc/supervisord.conf 

echo "[include]" | tee -a /opt/python/etc/supervisord.conf 
echo "files: celery.conf celerybeat.conf" | tee -a /opt/python/etc/supervisord.conf 

संपादित किया जाना चाहिए:

celerybeat चलाने के लिए, और यह सुनिश्चित करें कि यह केवल अपने सभी मशीनों पर एक बार से चलाने के लिए, आप अपने config फाइल में इन पंक्तियों से देना चाहिए -

04_killotherbeats: 
    command: "ps auxww | grep 'celery beat' | awk '{print $2}' | sudo xargs kill -9 || true" 
05_restartbeat: 
    command: "supervisorctl -c /opt/python/etc/supervisord.conf restart celerybeat" 
    leader_only: true 
+2

मुझे 'celerybeat.conf' में सेलेरीबीट कमांड में' --pidfile =/tmp/celerybeat.pid' जोड़ने के लिए भी (1) जोड़ना पड़ा था और (2) यह ठीक से काम करने के लिए 'ignoreErrors: true'' 04_killotherbeats 'जोड़ें एक लोचदार बीनस्टॉक कार्यकर्ता उदाहरण पर। –

+0

@ हकनबी। क्या आप इस बारे में विस्तार से बता सकते हैं कि मेरे अजवाइन राक्षस को यादृच्छिक रूप से मार दिया गया था और पर्यवेक्षक का हवाला देते हुए शुरू करने से इंकार कर रहा है? – gauravdott

+0

सबकुछ ठीक काम करता है लेकिन हर उदाहरण पर सेलेरीबीट लंच किया जाता है। नतीजा आवधिक कार्यों का दोहराव है ... –

संबंधित मुद्दे