Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run flask using production wsgi/http server #185

Merged
merged 18 commits into from
Aug 11, 2023

Conversation

daphnegold
Copy link
Contributor

@daphnegold daphnegold commented Aug 9, 2023

Ticket

Resolves #174

Changes

  • Add and configure gunicorn
  • Local and prod agnostic entrypoint in create_app(), remove app_config.environment
  • Remove __main__.py (this just adds another layer of complication that does nothing at this point except being an app factory wrapping an app factory)
  • Dockerfile starts gunicorn by default
  • docker-compose starts hot reloading Flask server, overriding gunicorn cmd in Dockerfile

Local via docker compose

Screenshot 2023-08-09 at 12 47 29 PM

Local with Gunicorn

Screenshot 2023-08-09 at 11 23 48 AM

Gunicorn running on AWS, 1 worker

Screenshot 2023-08-09 at 3 00 47 PM

Gunicorn running on AWS, 4 workers (available CPU x 2), 4 threads

Screenshot 2023-08-10 at 10 21 57 AM

@daphnegold daphnegold requested a review from lorenyu August 9, 2023 17:58
Copy link
Contributor

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome. can we test the following scenarios (and screenshots for evidence):

  • running locally using default method defined in docker compose
  • running in aws environment (also include screenshot of logs)
  • running locally using gunicorn

app/gunicorn.conf.py Outdated Show resolved Hide resolved
app/gunicorn.conf.py Show resolved Hide resolved
app/gunicorn.conf.py Show resolved Hide resolved
@daphnegold daphnegold force-pushed the daphnegold/issue-174-prod-server branch from 1a571a5 to e0b09ed Compare August 10, 2023 16:37
@lorenyu lorenyu changed the title [ISSUE 174] Run flask using production wsgi/http server Run flask using production wsgi/http server Aug 10, 2023
Copy link
Contributor

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR, thanks for the excellent work!

app/gunicorn.conf.py Outdated Show resolved Hide resolved
app/gunicorn.conf.py Outdated Show resolved Hide resolved
docs/app/database/database-access-management.md Outdated Show resolved Hide resolved
daphnegold and others added 4 commits August 11, 2023 08:55
Co-authored-by: Loren Yu <loren@navapbc.com>
Co-authored-by: Loren Yu <loren@navapbc.com>
Co-authored-by: Loren Yu <loren@navapbc.com>
@daphnegold daphnegold merged commit 5297c13 into main Aug 11, 2023
2 checks passed
@daphnegold daphnegold deleted the daphnegold/issue-174-prod-server branch August 11, 2023 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run flask using production wsgi/http server
2 participants