diff --git a/gunicorn.conf.py b/gunicorn.conf.py index b0d327c4..16a591bd 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -1,7 +1,5 @@ -import multiprocessing -workers = multiprocessing.cpu_count() * 2 + 1 -threads = multiprocessing.cpu_count() * 2 + 1 +workers = 1 worker_tmp_dir = '/dev/shm' @@ -9,6 +7,8 @@ bind = '0.0.0.0:5000' umask = 0o007 reload = False +worker_class = 'gevent' + #logging accesslog = '-' errorlog = '-' diff --git a/pyfedi.py b/pyfedi.py index 62df556d..47135a3f 100644 --- a/pyfedi.py +++ b/pyfedi.py @@ -1,5 +1,12 @@ # This file is part of pyfedi, which is licensed under the GNU General Public License (GPL) version 3.0. # You should have received a copy of the GPL along with this program. If not, see . + +from gevent import monkey +monkey.patch_all() + +from psycogreen.gevent import patch_psycopg +patch_psycopg() + from datetime import datetime from flask_babel import get_locale diff --git a/requirements.txt b/requirements.txt index 476f9833..56d82755 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,3 +33,5 @@ pytesseract==0.3.10 sentry-sdk==1.40.6 python-slugify==8.0.4 furl==2.1.3 +gevent +psycogreen