Tôi có một ứng dụng django trong đó nó có một chức năng cần tây, vì vậy tôi có thể có khả năng chạy cần tây thành công như dưới đâychạy cần tây như daemon sử dụng giám sát không hoạt động
celery -A tasks worker --loglevel=info
nhưng là một thực tế được biết rằng chúng ta cần phải chạy nó như là một daemon và vì vậy tôi đã viết dưới đây celery.conf
tập tin bên trong thư mục /etc/supervisor/conf.d/
; ==================================
; celery worker supervisor example
; ==================================
[program:celery]
; Set full path to celery program if using virtualenv
command=/root/Envs/proj/bin/celery -A app.tasks worker --loglevel=info
user=root
environment=C_FORCE_ROOT="yes"
environment=HOME="/root",USER="root"
directory=/root/apps/proj/structure
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
nhưng khi tôi đã cố gắng để cập nhật các giám sát như supervisorctl reread
và supervisorctl update
tôi đã nhận được thông báo từ 01.
celery FATAL Exited too quickly (process log may have details)
Vì vậy, tôi đã đi đến worker.log
tập tin và nhìn thấy thông báo lỗi như sau
Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=0 euid=0 gid=0 egid=0
Vậy tại sao người ta phàn nàn về C_FORCE_ROOT
mặc dù chúng tôi đã thiết lập nó như biến môi trường bên trong tập tin giám sát conf? những gì tôi đang làm sai trong tập tin conf ở trên?
Không chạy dưới dạng gốc - không cần thiết. (Bạn đang sử dụng điều này với Django - chạy như cùng một người dùng như ở đó.) –
yeah ok khi tôi loại bỏ dòng 'môi trường = HOME = "/ root", USER = "root" 'nó đã làm việc tốt –
Tôi đã có điều này vấn đề với AWS Elasticbeanstalk, sử dụng user = ec2-user đã sửa nó cho tôi –