Skip to content

Commit

Permalink
move main execution to __main__
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm committed Feb 2, 2025
1 parent daf959e commit 574d190
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ COPY --chown=1001:0 --chmod=664 ./docling_serve ./docling_serve

EXPOSE 5001

CMD ["python", "docling_serve/app.py"]
CMD ["python", "-m", "docling_serve"]
20 changes: 20 additions & 0 deletions docling_serve/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

from docling_serve.app import app
from docling_serve.helper_functions import _str_to_bool

# Launch the FastAPI server
if __name__ == "__main__":
from uvicorn import run

port = int(os.getenv("PORT", "5001"))
workers = int(os.getenv("UVICORN_WORKERS", "1"))
reload = _str_to_bool(os.getenv("RELOAD", "False"))
run(
app,
host="0.0.0.0",
port=port,
workers=workers,
timeout_keep_alive=600,
reload=reload,
)
17 changes: 0 additions & 17 deletions docling_serve/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,3 @@ async def process_file(
)

return response


# Launch the FastAPI server
if __name__ == "__main__":
from uvicorn import run

port = int(os.getenv("PORT", "5001"))
workers = int(os.getenv("UVICORN_WORKERS", "1"))
reload = _str_to_bool(os.getenv("RELOAD", "False"))
run(
"app:app",
host="0.0.0.0",
port=port,
workers=workers,
timeout_keep_alive=600,
reload=reload,
)

0 comments on commit 574d190

Please sign in to comment.