Information Systems:InfoNext server - gunicorn

From uniWIKI
Revision as of 15:53, 26 January 2018 by Norwinu (talk | contribs) (Created page with "==Overview== Gunicorn is the web server (written in Python) that is used to serve Infonext (Django). ==Background on Apache== Some background on Apache can help clarify the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Gunicorn is the web server (written in Python) that is used to serve Infonext (Django).

Background on Apache

Some background on Apache can help clarify the use of gunicorn server.

Apache is the most commonly known web server (maybe nginx too). It is also most commonly regarded as a web server. This is because it is widely used serve static web pages and files (e.g. HTML). However, Apache is also widely used as an application server and that is how Web Orders and Infonet "programs" are served. Apache is able to serve applications through the use of Apache modules. For WebSmart programs, which are in RPG and use CGI, the Apache module is mod_cgi (or some close variant). For serving Python/Django sites like Infonext, there are several modules available: mod_wsgi (wsgi), mod_fcgi (FastCGI), and mod_python. None are on the supported list of modules for IBM i HTTP Server (the flavor of Apache we use). Moreover, the community seems to recommend using alternative servers for performance reasons.

Besides being a web and application server, Apache can also act as a proxy (and reverse-proxy). That is, it can route URL requests to another server. Infonet programs are split into Infonet (WebSmart) and Infonext (Django) pages/apps. Thus, for Infonet programs, Apache will route and serve requests, while for Infonext requests, Apache will merely route them to Gunicorn.

Gunicorn

Gunicorn (installable with pip), is installed within the 'inx' virtual environment. It is scheduled to run daily (IBM i Job Scheduler) using the config file located at /inx/inx_gunicorn.py.

Important setup details include the following:

  • Runs on the same IP as Infonet (172.30.18.5), but on port 8080.
  • Apache proxies requests to '/inx' to Gunicorn.
  • An alias for '/static/' is defined, which maps to '/uwdsrc/inx/static'. Effectively, this means that the Python code within Infonext programs is served by Gunicorn, while the static files for Django (e.g. CSS, image files etc.) will be served like a normal folder by Apache.