|
import sys, os |
|
from dotenv import load_dotenv |
|
load_dotenv() |
|
|
|
sys.path.insert( |
|
0, os.path.abspath("../../..") |
|
) |
|
|
|
def start_rq_worker(): |
|
from rq import Worker, Queue, Connection |
|
from redis import Redis |
|
|
|
redis_conn = Redis(host=os.getenv("REDIS_HOST"), port=os.getenv("REDIS_PORT"), password=os.getenv("REDIS_PASSWORD")) |
|
print(redis_conn.ping()) |
|
|
|
try: |
|
queue = Queue(connection=redis_conn) |
|
worker = Worker([queue], connection=redis_conn) |
|
except Exception as e: |
|
print(f"Error setting up worker: {e}") |
|
exit() |
|
|
|
with Connection(redis_conn): |
|
worker.work() |
|
|
|
start_rq_worker() |