From 730254d36409b2ab2b94c35017cb7ee9f308e4fd Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 30 Jul 2023 04:44:15 +0300 Subject: [PATCH] add new env var WORKER_COUNT --- env_template.env | 1 + gunicorn.conf.py | 3 +++ scripts/s4 | 3 ++- scripts/startup_docker.sh | 2 +- services/rdrama-marseyworld.service | 2 +- services/rdrama.service | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/env_template.env b/env_template.env index 399fc43af..58f97d978 100644 --- a/env_template.env +++ b/env_template.env @@ -18,3 +18,4 @@ export DONATE_LINK='https://blahblahblah' export CF_KEY='blahblahblah' export CF_ZONE='blahblahblah' export DEBIAN_FRONTEND='noninteractive' +export WORKER_COUNT="2" diff --git a/gunicorn.conf.py b/gunicorn.conf.py index 4f344c089..9e1c9b327 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -1,8 +1,11 @@ +from os import environ + STARS = '\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n' bind = '0.0.0.0:5000' worker_class = 'gevent' +worker_count = int(environ.get("WORKER_COUNT").strip()) max_requests = 5000 max_requests_jitter = 10000 diff --git a/scripts/s4 b/scripts/s4 index 961d18d97..00eb5e729 100755 --- a/scripts/s4 +++ b/scripts/s4 @@ -2,4 +2,5 @@ cd /staging git pull . /e export SITE="staging.rdrama.net" -gunicorn files.__main__:app -w 1 -b 0.0.0.0:5002 -t 0 +export WORKER_COUNT="1" +gunicorn files.__main__:app -b 0.0.0.0:5002 -t 0 diff --git a/scripts/startup_docker.sh b/scripts/startup_docker.sh index ebe9a0e8b..5144da686 100755 --- a/scripts/startup_docker.sh +++ b/scripts/startup_docker.sh @@ -3,4 +3,4 @@ export DATABASE_URL='postgresql://postgres@postgres:5432' export REDIS_URL='redis://redis:6379' export PROXY_URL='http://opera-proxy:18080' /etc/init.d/nginx start -gunicorn files.__main__:app -w 2 +gunicorn files.__main__:app diff --git a/services/rdrama-marseyworld.service b/services/rdrama-marseyworld.service index 0514add85..fe32802de 100644 --- a/services/rdrama-marseyworld.service +++ b/services/rdrama-marseyworld.service @@ -12,7 +12,7 @@ Group = rdrama WorkingDirectory = /d ExecStartPre = /bin/mkdir /run/rdrama-marseyworld ExecStartPre = /bin/chown -R rdrama:rdrama /run/rdrama-marseyworld -ExecStart = /bin/bash -c 'set -a && source /e && SITE=marsey.world /usr/bin/env gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:5010 --max-requests 30000 --max-requests-jitter 30000 --pid /run/rdrama-marseyworld/rdrama-marseyworld.pid' +ExecStart = /bin/bash -c 'set -a && source /e && SITE=marsey.world && WORKER_COUNT=1 && /usr/bin/env gunicorn files.__main__:app -k gevent --reload -b 0.0.0.0:5010 --max-requests 30000 --max-requests-jitter 30000 --pid /run/rdrama-marseyworld/rdrama-marseyworld.pid' ExecReload = /bin/kill -s HUP $MAINPID ExecStop = /bin/kill -s TERM $MAINPID ExecStopPost = /bin/rm -rf /run/rdrama-marseyworld diff --git a/services/rdrama.service b/services/rdrama.service index fc1d8bb8f..70b698c82 100644 --- a/services/rdrama.service +++ b/services/rdrama.service @@ -12,7 +12,7 @@ Group = rdrama WorkingDirectory = /d ExecStartPre = /bin/mkdir /run/rdrama ExecStartPre = /bin/chown -R rdrama:rdrama /run/rdrama -ExecStart = /bin/bash -c 'set -a && source /e && /usr/bin/env gunicorn files.__main__:app -w 32 --pid /run/rdrama/rdrama.pid' +ExecStart = /bin/bash -c 'set -a && source /e && /usr/bin/env gunicorn files.__main__:app --pid /run/rdrama/rdrama.pid' ExecReload = /bin/kill -s HUP $MAINPID ExecStop = /bin/kill -s TERM $MAINPID ExecStopPost = /bin/rm -rf /run/rdrama