'Why celery module isn't available when running celery as a daemon with supervisor?
I'm trying to daemonize my project on VPS. If I am running the celery from command line as
celery -A taxomat_api worker -B -l INFO
or
/var/www/html/taxomat/taxomat_api/venv/bin/celery --workdir=/var/www/html/taxomat/taxomat_api -A taxomat_api worker -B -l INFO
or
cd /var/www/html/taxomat/taxomat_api
root@taxomat:/var/www/html/taxomat/taxomat_api# venv/bin/celery -A taxomat_api worker -B -l INFO
everything works good, but now when I'm trying to run celery tasks as daemon with supervisor, I have an error
Traceback(most recent call last):
File "/var/www/html/taxomat/taxomat_api/venv/bin/celery", line 5, in <module>
from celery.__main__ import main
File "/var/www/html/taxomat/taxomat_api/celery.py", line4, in <module>
ModuleNotFoundError: No module named 'celery.schedules'; 'celery' is not a package
Here is my conf file /path /etc/supervisor/conf.d/celery.conf/
[program:deeptechx-celery]
environment=PYTHONPATH="/var/www/html/taxomat/taxomat_api:$PYTHONPATH",DJANGO_SETTINGS_MODULE="taxomat_api.settings"
command=/var/www/html/taxomat/taxomat_api/venv/bin/celery --workdir=/var/www/html/taxomat/taxomat_api -A taxomat_api worker -B -l INFO
directory=/var/www/html/taxomat/taxomat_api
user=root
numprocs=1
stdout_logfile=/var/log/celery/worker.log
stderr_logfile=/var/log/celery/worker.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=1
My project tree is
taxomat
taxomat_api
venv
bin
celery
lib
python3.8
taxomat_api
settings.py
celery.py
workers
tasks.py
My celery.py file
from __future__ import absolute_import, unicode_literals
import os
from celery.schedules import crontab
from celery import Celery
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'taxomat_api.settings')
django.setup()
app = Celery('taxomat_api')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
On my local machine daemon works too. Can anybody help me? I have read docs, try many ways but the error is the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
