gunicorn config

This commit is contained in:
Daniel Grams 2020-12-29 14:14:04 +01:00
parent f1066409b9
commit 3200e77925
4 changed files with 15 additions and 8 deletions

View File

@ -1,2 +1,2 @@
release: flask db upgrade
web: gunicorn project:app --log-file=-
web: gunicorn -c gunicorn.conf.py project:app

View File

@ -31,10 +31,12 @@ psql -c 'create database gsevpt;' -U postgres
### Install and run
```sh
export DATABASE_URL="postgresql://postgres@localhost/gsevpt"
pip install -r requirements.txt
flask db upgrade
gunicorn --bind 0.0.0.0:5000 project:app
python3 -m venv venv
source venv/bin/activate
(venv) pip install -r requirements.txt
(venv) export DATABASE_URL='postgresql://postgres@localhost/gsevpt'
(venv) flask db upgrade
(venv) gunicorn -c gunicorn.conf.py --bind 0.0.0.0:5000 project:app
```
## Scheduled/Cron jobs
@ -61,8 +63,8 @@ Create `.env` file in the root directory or pass as environment variables.
| Variable | Function |
| --- | --- |
| SECRET_KEY | A secret key for verifying the integrity of signed cookies. Generate a nice key using secrets.token_urlsafe(). |
| SECURITY_PASSWORD_HASH | Bcrypt is set as default SECURITY_PASSWORD_HASH, which requires a salt. Generate a good salt using: secrets.SystemRandom().getrandbits(128). |
| SECRET_KEY | A secret key for verifying the integrity of signed cookies. Generate a nice key using `python3 -c "import secrets; print(secrets.token_urlsafe())"`. |
| SECURITY_PASSWORD_HASH | Bcrypt is set as default SECURITY_PASSWORD_HASH, which requires a salt. Generate a good salt using: `python3 -c "import secrets; print(secrets.SystemRandom().getrandbits(128))"`. |
### Send notifications via Mail

View File

@ -7,4 +7,4 @@ do
done
BIND_PORT=${PORT:-5000}
gunicorn --bind 0.0.0.0:$BIND_PORT project:app
gunicorn -c gunicorn.conf.py --bind 0.0.0.0:$BIND_PORT project:app

5
gunicorn.conf.py Normal file
View File

@ -0,0 +1,5 @@
import multiprocessing
workers = multiprocessing.cpu_count() * 2 + 1
capture_output = True
errorlog = "-"