arq
arq copied to clipboard
Arq server connects to redis at localhost by default
I was using arq in a new project and everything was working fine on local machine as it was connecting to redis on localhost. But when i deployed the service to some environment, following error starts popping. The error say's unable to connect to redis on localhost. I was wondering why ARQ trying to connect redis at localhost as i've pointed localhost to some other host. After seeing arq code, found out we have to keep a class variable redis_settings inside WorkerSettings class and that should be initialised with RedisSettings with the actual redis host and port. Following is the example:
class WorkerSettings:
redis_config = CONFIG.config['ARQ_REDIS']
redis_settings = RedisSettings(host=redis_config['HOST'], port=redis_config['PORT'])
functions = [method1, method2]
cron_config = CONFIG.config["ARQ_CRON"]
cron_jobs = [
cron(cron_method1, second=cron_config["SEC"])
]
Error when redis_settings variable was not set:
14:26:14: redis connection error ('localhost', 6379) OSError Multiple exceptions: [Errno 111] Connection refused, [Errno 99] Cannot assign requested address, 5 retries remaining...
14:26:15: redis connection error ('localhost', 6379) OSError Multiple exceptions: [Errno 111] Connection refused, [Errno 99] Cannot assign requested address, 4 retries remaining...
14:26:16: redis connection error ('localhost', 6379) OSError Multiple exceptions: [Errno 111] Connection refused, [Errno 99] Cannot assign requested address, 3 retries remaining...
14:26:17: redis connection error ('localhost', 6379) OSError Multiple exceptions: [Errno 111] Connection refused, [Errno 99] Cannot assign requested address, 2 retries remaining...
^C14:26:18: shutdown on SIGINT ◆ 0 jobs complete ◆ 0 failed ◆ 0 retries ◆ 0 ongoing to cancel
I think the above code should be provided in the documentation to avoid this problem.
@cmangla @samuelcolvin please help
Got the issue, basically arq server tries to connect to redis on localhost if redis_settings variable is not passed. This example is not considered in documents. Please pass redis_settings variable in the WorkerSettings in the document
Can you make the issue readable.
This is documented through #279 😊