mac_1010
mac_1010

Reputation: 3

Setting up Celery with Redis on a server for a Django app

I am trying to set up my django project to work with Celery and Redis. I have no issues running it locally, but I can't get it working in the production server.

My hosting recommends to setup Redis using unixsocket and run redis in a screen:

This all works, when I run redis I get:

* The server is now ready to accept connections at /here-comes-my-path/redis.sock

Now I have issues:

  1. How do I verify the connection? redis-cli -p 0 returns Could not connect to Redis at 127.0.0.1:0: Can't assign requested address not connected>
  2. How do I start celery worker? Running celery -A rbwpredictor worker -l info returns (I've xed sensitive data):

    Traceback (most recent call last):
    

    File "/usr/home/xxxx/.virtualenvs/xxxx/bin/celery", line 6, in from celery.main import main File "/home/xxx/domains/xxxx/public_python/xxxx/celery.py", line 6, in from celery import Celery ImportError: cannot import name 'Celery'

My Celery settings in settings.py:

CELERY_RESULT_BACKEND = 'django-db'
CELERY_STATUS_PENDING = 'PENDING'
CELERY_STATUS_STARTED = 'STARTED'
CELERY_STATUS_RETRY = 'RETRY'
CELERY_STATUS_FAILURE = 'FAILURE'
CELERY_STATUS_SUCCESS = 'SUCCESS'

As mentioned above locally everything works fine, it's the configuration on the server I struggle with.

Upvotes: 0

Views: 369

Answers (1)

iklinac
iklinac

Reputation: 15748

You have configured redis to communicate through unix socket not through standard port

To connect with redis-cli you can use

redis-cli -s /here-comes-my-path/redis.sock

And you should reconfigure redis.conf or just set BROKER_URL

BROKER_URL = 'redis+socket:///here-comes-my-path/redis.sock'

Upvotes: 1

Related Questions