import os
import redis
from rq import Worker, Queue
from env_info import environment_var
listen = ["default"]
if environment_var == 'DEV':
    redis_url = os.getenv("REDISTOGO_URL", "redis://localhost:6380")
    conn = redis.from_url(redis_url)
else:
    redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6381')
    conn = redis.from_url(redis_url)


if __name__ == "__main__":
    print("Redis connected")
    
    # Create queues by explicitly passing the connection
    queues = [Queue(name, connection=conn) for name in listen]
    
    # Pass the queues (which now hold the connection) to the Worker
    worker = Worker(queues, connection=conn)
    worker.work()
