set uwsgi procs based on cpu count

This commit is contained in:
wh1te909 2021-02-27 05:28:42 +00:00
parent 2ea8742510
commit 9e6cbd3d32
3 changed files with 70 additions and 16 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="40"
SCRIPT_VERSION="41"
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/install.sh'
sudo apt install -y curl wget dirmngr gnupg lsb-release
@ -406,6 +406,12 @@ python manage.py generate_barcode ${RANDBASE} ${djangousername} ${frontenddomain
deactivate
read -n 1 -s -r -p "Press any key to continue..."
uwsgiprocs=4
if [[ "$numprocs" == "1" ]]; then
uwsgiprocs=2
else
uwsgiprocs=$numprocs
fi
uwsgini="$(cat << EOF
[uwsgi]
@ -413,8 +419,8 @@ chdir = /rmm/api/tacticalrmm
module = tacticalrmm.wsgi
home = /rmm/api/env
master = true
processes = 6
threads = 6
processes = ${uwsgiprocs}
threads = ${uwsgiprocs}
enable-threads = true
socket = /rmm/api/tacticalrmm/tacticalrmm.sock
harakiri = 300
@ -423,7 +429,6 @@ buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 500
max-requests-delta = 1000
EOF
)"
echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini

View File

@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="19"
SCRIPT_VERSION="20"
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/restore.sh'
sudo apt update
@ -242,9 +242,36 @@ npm install meshcentral@${MESH_VER}
print_green 'Restoring the backend'
numprocs=$(nproc)
uwsgiprocs=4
if [[ "$numprocs" == "1" ]]; then
uwsgiprocs=2
else
uwsgiprocs=$numprocs
fi
uwsgini="$(cat << EOF
[uwsgi]
chdir = /rmm/api/tacticalrmm
module = tacticalrmm.wsgi
home = /rmm/api/env
master = true
processes = ${uwsgiprocs}
threads = ${uwsgiprocs}
enable-threads = true
socket = /rmm/api/tacticalrmm/tacticalrmm.sock
harakiri = 300
chmod-socket = 660
buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 500
EOF
)"
echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini
cp $tmp_dir/rmm/local_settings.py /rmm/api/tacticalrmm/tacticalrmm/
cp $tmp_dir/rmm/env /rmm/web/.env
cp $tmp_dir/rmm/app.ini /rmm/api/tacticalrmm/
gzip -d $tmp_dir/rmm/debug.log.gz
cp $tmp_dir/rmm/debug.log /rmm/api/tacticalrmm/tacticalrmm/private/log/
cp $tmp_dir/rmm/mesh*.exe /rmm/api/tacticalrmm/tacticalrmm/private/exe/

View File

@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="112"
SCRIPT_VERSION="113"
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/update.sh'
LATEST_SETTINGS_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py'
YELLOW='\033[1;33m'
@ -172,6 +172,37 @@ printf >&2 "${GREEN}Stopping ${i} service...${NC}\n"
sudo systemctl stop ${i}
done
rm -f /rmm/api/tacticalrmm/app.ini
numprocs=$(nproc)
uwsgiprocs=4
if [[ "$numprocs" == "1" ]]; then
uwsgiprocs=2
else
uwsgiprocs=$numprocs
fi
uwsgini="$(cat << EOF
[uwsgi]
chdir = /rmm/api/tacticalrmm
module = tacticalrmm.wsgi
home = /rmm/api/env
master = true
processes = ${uwsgiprocs}
threads = ${uwsgiprocs}
enable-threads = true
socket = /rmm/api/tacticalrmm/tacticalrmm.sock
harakiri = 300
chmod-socket = 660
buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 500
EOF
)"
echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini
# forgot to add this in install script. catch any installs that don't have it enabled and enable it
sudo systemctl enable natsapi.service
@ -230,15 +261,6 @@ sudo chown -R $USER:$GROUP /home/${USER}/.cache
sudo chown ${USER}:${USER} -R /etc/letsencrypt
sudo chmod 775 -R /etc/letsencrypt
CHECK_BUFF_SIZE=$(grep buffer-size /rmm/api/tacticalrmm/app.ini)
if ! [[ $CHECK_BUFF_SIZE ]]; then
setbuff="$(cat << EOF
buffer-size = 65535
EOF
)"
echo "${setbuff}" | tee --append /rmm/api/tacticalrmm/app.ini > /dev/null
fi
CHECK_REMOVE_SALT=$(grep KEEP_SALT /rmm/api/tacticalrmm/tacticalrmm/local_settings.py)
if ! [[ $CHECK_REMOVE_SALT ]]; then
printf >&2 "${YELLOW}This update removes salt from the rmm${NC}\n"