Skip to content

Commit

Permalink
replace waitress with hypercorn
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed Mar 25, 2024
1 parent 52aa6f3 commit 4429ad9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ ARG TZ=America/New_York
ENV USER=${USER}
ENV TZ=${TZ}

ARG PROJECT_NAME
ENV PROJECT_NAME=${PROJECT_NAME}

ARG PROJECT_PATH=/app
ENV PROJECT_PATH=${PROJECT_PATH}

ENV PYTHON_DEPS_PATH=/dependencies
ENV PYTHONPATH="${PYTHONPATH}:${PYTHON_DEPS_PATH}"
ENV PYTHONUNBUFFERED=TRUE

ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
Expand Down Expand Up @@ -151,9 +156,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER} && \
chmod 0440 /etc/sudoers.d/${USER}

ARG PROJECT_NAME
ENV PROJECT_NAME=${PROJECT_NAME}

ENV DOTFILES_URL=https://github.com/ilude/dotfiles.git

USER ${USER}
Expand Down
9 changes: 7 additions & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ def index():

if __name__ == '__main__':
port = int(os.environ.get("ONBOARD_PORT", 9830))
print(f"Starting {os.environ.get('PROJECT_NAME', 'OnBoard').title()} server on port {port}")
if os.environ.get("FLASK_DEBUG", "False") == "True":
app.run(port=port, debug=True)
else:
from waitress import serve
serve(app, host='0.0.0.0', port=port)
import asyncio
from hypercorn.config import Config
from hypercorn.asyncio import serve
config = Config()
config.bind = [f"0.0.0.0:{port}"]
asyncio.run(serve(app, config))
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ lxml
python-dotenv
pyyaml
requests
waitress
hypercorn

0 comments on commit 4429ad9

Please sign in to comment.