Skip to content

Commit

Permalink
Merge pull request #29 from TogetherCrew/update-module-name
Browse files Browse the repository at this point in the history
Update module name and added env examples!
  • Loading branch information
cyri113 authored Oct 16, 2023
2 parents 86154ed + 252359f commit 0e2c95e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 48 deletions.
24 changes: 23 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
GITHUB_TOKEN=daolytics_access_token
AUTOMATION_DB_COLLECTION=
AUTOMATION_DB_NAME=
MONGODB_HOST=
MONGODB_PASS=
MONGODB_PORT=
MONGODB_USER=
NEO4J_DB=
NEO4J_HOST=
NEO4J_PASSWORD=
NEO4J_PORT=
NEO4J_PROTOCOL=
NEO4J_USER=
RABBIT_HOST=
RABBIT_PASSWORD=
RABBIT_PORT=
RABBIT_USER=
REDIS_HOST=
REDIS_PASSWORD=
REDIS_PORT=
SAGA_DB_COLLECTION=
SAGA_DB_NAME=
SENTRY_DSN=
SENTRY_ENV=
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN chmod +x docker-entrypoint.sh
CMD ["./docker-entrypoint.sh"]

FROM base AS prod
CMD ["python3", "start_rabbit_mq.py"]
CMD ["python3", "server.py"]
2 changes: 1 addition & 1 deletion docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
target: prod
dockerfile: Dockerfile
command: python3 start_rabbit_mq.py
command: python3 server.py
worker:
build:
context: .
Expand Down
34 changes: 0 additions & 34 deletions redis_worker.py

This file was deleted.

File renamed without changes.
19 changes: 8 additions & 11 deletions worker.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import logging
import os

import redis
from dotenv import load_dotenv
from rq import Worker

load_dotenv()
from utils.daolytics_uitls import get_redis_credentials


def worker_exception_handler(job, exc_type, exc_value, traceback):
Expand All @@ -17,18 +14,18 @@ def worker_exception_handler(job, exc_type, exc_value, traceback):


if __name__ == "__main__":
host = os.getenv("REDIS_HOST", "")
port = int(os.getenv("REDIS_PORT", 6379))
password = os.getenv("REDIS_PASSWORD")
redis_creds = get_redis_credentials()

logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)

redis_connection = redis.Redis(host=host, port=port, password=password)
host = redis_creds["host"]
port = redis_creds["port"]
password = redis_creds["pass"]

r = redis.Redis(host=host, port=port, password=password)
worker = Worker(
queues=["default"],
connection=redis_connection,
exception_handlers=worker_exception_handler,
queues=["default"], connection=r, exception_handlers=worker_exception_handler
)
try:
worker.work(with_scheduler=True, max_jobs=1)
Expand Down

0 comments on commit 0e2c95e

Please sign in to comment.