Skip to content

Commit f673978

Browse files
committed
Update Gunicorn configuration.
1 parent 0f5995e commit f673978

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Get set up locally in two steps:
2525
Replace the values in **.env.example** with your values and rename this file to **.env**:
2626

2727
* `ENVIRONMENT`: Enable (`development` or `production`).
28-
* `FLASK_APP`: Entry point of your application; should be `main.py`.
28+
* `FLASK_APP`: Entry point of your application; should be `wsgi.py`.
2929
* `FLASK_DEBUG`: Toggle debug mode on (`True`) or off (`False`).
3030
* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data.
3131
* `SQLALCHEMY_DATABASE_URI`: Connection URI of a SQL database (ie: `mysql+pymysql://myuser:[email protected]:1234/mydatabase`)

gunicorn.conf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
from dotenv import load_dotenv
55

6+
# Read environment variables from ".env" file.
67
basedir = path.abspath(path.dirname(__file__))
78
load_dotenv(path.join(basedir, ".env"))
89

10+
# Fetch deployment environment from environment variables.
911
ENVIRONMENT = environ.get("ENVIRONMENT")
1012

1113
proc_name = "flasksession"
@@ -14,15 +16,16 @@
1416
threads = 4
1517
workers = 2
1618

17-
if ENVIRONMENT == "development":
19+
if ENVIRONMENT == "development" or ENVIRONMENT is None:
1820
reload = True
1921
workers = 1
2022
threads = 1
2123
bind = ["127.0.0.1:8000"]
22-
23-
if ENVIRONMENT == "production":
24+
elif ENVIRONMENT == "production":
2425
daemon = True
2526
accesslog = "/var/log/flasksession/access.log"
2627
errorlog = "/var/log/flasksession/error.log"
2728
loglevel = "trace"
2829
dogstatsd_tags = "env:prod,service:flasksession,language:python"
30+
else:
31+
raise ValueError(f"Unknown environment provided: `{ENVIRONMENT}`. Must be `development` or `production`.")

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ authors = ["Todd Birchard <[email protected]>"]
66
maintainers = ["Todd Birchard <[email protected]>"]
77
license = "MIT"
88
readme = "README.md"
9-
homepage = "https://hackersandslackers.com/managing-user-session-variables-with-flask-sessions-and-redis/"
9+
homepage = "https://hackersandslackers.com/flask-user-sessions-and-redis/"
1010
repository = "https://github.com/hackersandslackers/flask-session-tutorial/"
11-
documentation = "https://hackersandslackers.com/managing-user-session-variables-with-flask-sessions-and-redis/"
11+
documentation = "https://hackersandslackers.com/flask-user-sessions-and-redis/"
1212
keywords = ["Flask", "Flask-Session", "Redis", "User sessions", "Tutorial"]
1313

1414
[tool.poetry.dependencies]

0 commit comments

Comments
 (0)