-
Notifications
You must be signed in to change notification settings - Fork 6
Run flask using production wsgi/http server #185
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fe43fc5
Add Gunicorn dependency
daphnegold 84dc243
Configure gunicorn.conf.py
daphnegold dd27443
Dockerfile should use gunicorn by default with cmd
daphnegold 58964b9
Docker compose overrides Dockerfile cmd with Flask run + no gunicorn
daphnegold 9e7e7d9
Remove __main__.py as all entrypoints to app can go through standard …
daphnegold 3eaf43f
Remove environment, app no longer needs it
daphnegold 2319913
Adjust references to __main__.py
daphnegold d11416f
Hardcode 4 threads
daphnegold 58c4ffc
Add docstring and comments to gunicorn.conf.py, num threads
daphnegold 5dee58d
Remove duplicate workdir setting, add tmp dir
daphnegold ba0b9bc
Add comment on Gunicorn workaround in Dockerfile
daphnegold e0b09ed
Add comment for workers
daphnegold 6caf3cf
Merge branch 'main' into daphnegold/issue-174-prod-server
daphnegold 220e299
Fix typo
daphnegold 5e37428
Update app/gunicorn.conf.py
daphnegold c371bb4
Update app/gunicorn.conf.py
daphnegold 218ac00
Update docs/app/database/database-access-management.md
daphnegold 62ee0c1
Update comment on workers with info on CPU methods
daphnegold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """ | ||
| Configuration file for the Gunicorn server used to run the application in production environments. | ||
|
|
||
| Attributes: | ||
| bind(str): The socket to bind. Formatted as '0.0.0.0:$PORT'. | ||
| workers(int): The number of worker processes for handling requests. | ||
| threads(int): The number of threads per worker for handling requests. | ||
|
|
||
| For more information, see https://docs.gunicorn.org/en/stable/configure.html | ||
| """ | ||
|
|
||
| import os | ||
daphnegold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| from src.app_config import AppConfig | ||
|
|
||
| app_config = AppConfig() | ||
|
|
||
| bind = app_config.host + ':' + str(app_config.port) | ||
| # Calculates the number of usable cores and doubles it. Recommended number of workers per core is two. | ||
| # https://docs.gunicorn.org/en/latest/design.html#how-many-workers | ||
daphnegold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # We use 'os.sched_getaffinity(pid)' not 'os.cpu_count()' because it returns only allowable CPUs. | ||
| # os.sched_getaffinity(pid): Return the set of CPUs the process with PID pid is restricted to. | ||
| # os.cpu_count(): Return the number of CPUs in the system. | ||
| workers = len(os.sched_getaffinity(0)) * 2 | ||
| threads = 4 | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.