Skip to content

Commit

Permalink
srv: implement gunicorn wsgi
Browse files Browse the repository at this point in the history
This patch implements the Gunicorn WSGI server.

Signed-off-by: Amy Parker <amy@amyip.net>
  • Loading branch information
amyipdev committed Jul 30, 2023
1 parent 67a3d8b commit dd773f3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ mysql-connector-python
ping3
requests
psycopg2
pyopenssl
pyopenssl
gunicorn
50 changes: 50 additions & 0 deletions srv/gunicorn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# ssvp: server statistics viewer project
# Copyright (C) 2023 Amy Parker <amy@amyip.net>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit the
# GNU Project at https://gnu.org/licenses. The GNU Affero General Public
# License version 3 is available at, for your convenience,
# https://www.gnu.org/licenses/agpl-3.0.en.html.

which jq
if [ $? -ne 0 ]; then
echo "jq not found"
exit 1
fi

set -e

cd "$(dirname "$0")"

SSL=$(jq -j .ssl ssvp-config.json)
PORT=$(jq -j .port ssvp-config.json)

if [ $PORT == "null" ]; then
if [ $SSL != "null" ]; then
PORT=443
else
PORT=80
fi
fi

if [ $(jq -j .enable_host_ipv6 ssvp-config.json) != "true" ]; then
BINDADDR="0.0.0.0:$PORT"
else
BINDADDR="[::]:$PORT"
fi

gunicorn -w $(( $(nproc) * 2 )) 'app:app' -b $BINDADDR

0 comments on commit dd773f3

Please sign in to comment.