Ubuntu 20+ + Flask + Gunicorn + Supervisor + Nginx

Ubuntu 20+ + Flask + Gunicorn + Supervisor + Nginx Publish Python API

 · 1 min read

run.sh in project folder

#!/bin/bash -e


if [ -f .venv/bin/activate ]; then

  echo "Load Python virtualenv from '.venv/bin/activate'"

  source .venv/bin/activate

fi

exec "$@"




supervisord -n

$ /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf


/opt/sip-api/run.sh gunicorn -c /etc/gunicorn.conf.py sample:app


gunicorn.conf.py below

import os

import multiprocessing


_ROOT = os.path.abspath(os.path.join(

  os.path.dirname(__file__), '..'))

_VAR = os.path.join(_ROOT, 'var')

_ETC = os.path.join(_ROOT, 'etc')


loglevel = 'info'

# errorlog = os.path.join(_VAR, 'log/api-error.log')

# accesslog = os.path.join(_VAR, 'log/api-access.log')

errorlog = "-"

accesslog = "-"


# bind = 'unix:%s' % os.path.join(_VAR, 'run/gunicorn.sock')

bind = '0.0.0.0:5500'

# workers = 3

workers = multiprocessing.cpu_count() * 2 + 1


timeout = 3 * 60 # 3 minutes

keepalive = 24 * 60 * 60 # 1 day


capture_output = True

---------------------------


Supervisor has two files.

https://github.com/ERPGulf/docs/blob/main/frappe-bench.conf

https://github.com/ERPGulf/docs/blob/main/xxx.ini


It's very important to have all the folders mentioned in supervisor configuration files exists and proper permission granted.  Otherwise you will hit wil either service hang or get error "supervisor Error: Cannot open an HTTP server: socket.error reported errno.ENOENT "


-------------------------------------------------



Cloud support

Cloud support team provides hosting related support and technology updates. Cover technology like cloud printing, Cloud PBAX, VoIP, Kubernetes, Ubuntu, Linux etc. Contact us on support@ERPGulf.com

No comments yet

No comments yet. Start a new discussion.

Add Comment