Skip to content

Commit

Permalink
refactor: Update Dockerfile.development to run app with uvicorn and w…
Browse files Browse the repository at this point in the history
…atch.py
  • Loading branch information
luthfiarifin committed Sep 26, 2024
1 parent 2ef18b2 commit 5759cde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ COPY ./app ./app
# Install FastAPI separately to leverage Docker cache
RUN pip install "fastapi[standard]"

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080", "--reload"]
CMD ["sh", "-c", "python app/events/watch.py & uvicorn main:app --host 0.0.0.0 --port 8080 --reload"]
24 changes: 12 additions & 12 deletions app/events/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from crud import insert_event_vector, update_event_vector, eventCollections


change_stream = eventCollections.watch()
for change in change_stream:
if change["operationType"] == "insert":
insert_event_vector(change["fullDocument"])
elif change["operationType"] == "update":
print(change["documentKey"]["_id"])
update_event_vector(
change["documentKey"]["_id"],
change["updateDescription"]["updatedFields"],
)
print(dumps(change))
if __name__ == "__main__":
change_stream = eventCollections.watch()
for change in change_stream:
if change["operationType"] == "insert":
insert_event_vector(change["fullDocument"])
elif change["operationType"] == "update":
print(change["documentKey"]["_id"])
update_event_vector(
change["documentKey"]["_id"],
change["updateDescription"]["updatedFields"],
)
print(dumps(change))

0 comments on commit 5759cde

Please sign in to comment.