Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
added environmental variable for redis endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreycwitt committed Feb 8, 2020
1 parent a62e287 commit 246afbc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ services:
- 5000:5000
volumes:
- ../lbp-print-cache:/usr/src/app/cache
environment:
- REDIS_DOCKER=True
queue-worker:
build: .
command: python3 worker.py
depends_on:
- redis
volumes:
- ../lbp-print-cache:/usr/src/app/cache
environment:
- REDIS_DOCKER=True
redis:
image: "redis:alpine"
6 changes: 4 additions & 2 deletions processor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging

import os
import urllib

from redis import Redis
Expand All @@ -13,7 +13,9 @@

logger = logging.getLogger()
lbp_config.cache_dir = "cache"
redis_connection = Redis(host="localhost")
redis_endpoint = "redis" if os.environ.get("REDIS_DOCKER") == "True" else "localhost"
logger.warning(f"Logging redis endpoint: {redis_endpoint}")
redis_connection = Redis(host=redis_endpoint)
q = Queue(connection=redis_connection)


Expand Down
5 changes: 3 additions & 2 deletions worker.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env python
import sys

import os
from redis import Redis
from rq import Connection, Worker


def start_worker(queues: list = ["default"]):
redis_endpoint = "redis" if os.environ.get("REDIS_DOCKER") == "True" else "localhost"
with Connection():
w = Worker(queues, connection=Redis(host="localhost"))
w = Worker(queues, connection=Redis(host=redis_endpoint))
w.work()


Expand Down

0 comments on commit 246afbc

Please sign in to comment.