Skip to content

Commit b524743

Browse files
committed
Add Gunicorn configuration.
1 parent 51923fd commit b524743

File tree

4 files changed

+189
-158
lines changed

4 files changed

+189
-158
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $(VIRTUAL_ENV):
3333
.PHONY: run
3434
run: env
3535
export LESS_BIN=$(shell which lessc) && \
36-
$(LOCAL_PYTHON) -m gunicorn -w 4 wsgi:app
36+
$(LOCAL_PYTHON) -m gunicorn --config=gunicorn.conf.py
3737

3838
.PHONY: install
3939
install: env

gunicorn.conf.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Gunicorn configuration file."""
2+
from os import environ, path
3+
4+
from dotenv import load_dotenv
5+
6+
basedir = path.abspath(path.dirname(__file__))
7+
load_dotenv(path.join(basedir, ".env"))
8+
9+
ENVIRONMENT = environ.get("ENVIRONMENT")
10+
11+
proc_name = "flasksession"
12+
wsgi_app = "wsgi:app"
13+
bind = "unix:flask.sock"
14+
threads = 4
15+
workers = 2
16+
17+
if ENVIRONMENT == "development":
18+
reload = True
19+
workers = 1
20+
threads = 1
21+
bind = ["127.0.0.1:8000"]
22+
23+
if ENVIRONMENT == "production":
24+
daemon = True
25+
accesslog = "/var/log/flasksession/access.log"
26+
errorlog = "/var/log/flasksession/error.log"
27+
loglevel = "trace"
28+
dogstatsd_tags = "env:prod,service:flasksession,language:python"

0 commit comments

Comments
 (0)