Answer a question

I need help with start Celery daemon as smart-attach-daemon in uWSGI.ini file.

When i start Celery server from command line with command: /home/xxxxx/xxxxx/venv/bin/celery worker -A celery_worker.celery --loglevel=info --purge all works great.

But i don't know how start this server as daemon.

In documentation (http://uwsgi-docs.readthedocs.io/en/latest/AttachingDaemons.html) are information:

Managing celery:

[uwsgi]
master = true
socket = :3031
smart-attach-daemon = /tmp/celery.pid celery -A tasks worker --pidfile=/tmp/celery.pid

When i use:

smart-attach-daemon = %(base)aaa/celery.pid %(base)venv/bin/celery worker --pidfile=%(base)aaa/celery.pid --config=%(base)celeryconfig.py --workdir=%(base)app

in logs i see:

[uwsgi-daemons] found valid/active pidfile for "/home/xxxx/xxxxx/venv/bin/celery worker --pidfile=/home/xxxx/xxxxx/aaa/celery.pid --config=/home/xxxx/xxxxx/celeryconfig.py" (pid: 6901)

and Celery probably works fine.

But when i try add "-A" parameter for my worker:

smart-attach-daemon = %(base)aaa/celery.pid %(base)venv/bin/celery -A celery_worker.celery --pidfile=%(base)aaa/celery.pid --config=%(base)celeryconfig.py --workdir=%(base)app

in log i see error message:

ImportError: No module named 'celery_worker'

Please, how i can start my Celery server with specific worker file?

Or, how i can run command:

`/home/xxxxx/xxxxx/venv/bin/celery worker -A celery_worker.celery --loglevel=info --purge

as smart-attach-daemon?

Thanks for any answers.

Answers

Can you post your entire uwsgi config file?

I reckon it has something to do with uwsgi not properly recognizing your virtualenv directory/PYTHONPATH.

Try adding these to your uwsgi file:

[uwsgi]
chdir = /home/xxxxx/xxxxx
home = /home/xxxxx/xxxxx/venv/
...
Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐