-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run flask using production wsgi/http server (#185)
- Loading branch information
1 parent
75df51b
commit 5297c13
Showing
8 changed files
with
55 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 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 | ||
|
||
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 | ||
# 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 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 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 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 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