Skip to content

Commit

Permalink
added database queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerskk committed Jul 26, 2024
1 parent 988608e commit 6b43b9b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/api/endpoints/ontologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def build_from_scratch():
urls.append(url.decode().strip())

for url in urls:
chain(add_ontology_task.s(url), add_ontologies.s()).apply_async()
chain(add_ontology_task.s(url), add_ontologies.s().set(queue='neo4j_write_queue')).apply_async()

return Response(status_code=status.HTTP_204_NO_CONTENT)

Expand Down
3 changes: 2 additions & 1 deletion init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ echo "starting swobup..."

echo "starting celery"
celery -A tasks worker -l info &
celery -A tasks worker --queues=database_queue --concurrency=1 &
celery -A tasks flower -l info --port=1111 &
echo "starting uvicorn"
uvicorn --workers 10 --host 0.0.0.0 --port 8000 main:app
uvicorn --workers 10 --host 0.0.0.0 --port 8000 main:app
21 changes: 20 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,23 @@
app.conf["s3_endpoint_url"] = os.environ.get("s3_endpoint_url")
app.conf["s3_region"] = os.environ.get("s3_region")

print("configuration: ", app.conf)

# Define the queues
app.conf.task_queues = {
'default': {
'exchange': 'default',
'binding_key': 'default'
},
'database_queue': {
'exchange': 'database_queue',
'binding_key': 'database_queue'
}
}

# Define the routes
app.conf.task_routes = {
'app.tasks.add_to_database': {'queue': 'database_queue'},
'*': {'queue': 'default'} # All other tasks go to the default queue
}

print("configuration: ", app.conf)

0 comments on commit 6b43b9b

Please sign in to comment.