Flask app with virtual Python environment in Unit 1.1 ?
    Ralph Seichter 
    m16+nginx at monksofcool.net
       
    Sun Apr 29 14:10:08 UTC 2018
    
    
  
Hello,
I have built a Flask application with a Python 3.6 virtual environment
which I would like to run using NGINX Unit 1.1 instead of the usual
"source venv/bin/activate; flask run". When I try to apply the following
configuration
  {
    "listeners": {
      "*:5080": {
        "application": "myapp"
      }
    },
    "applications": {
      "myapp": {
        "type": "python",
        "processes": 1,
        "module": "wsgi",
        "user": "nginx",
        "group": "nginx",
        "path": "/var/www/myapp"
      }
    }
  }
My log file shows
  [info] 21422#21422 "myapp" application started
  [alert] 21422#21422 Python failed to import module "wsgi"
  [notice] 20803#20803 process 21422 exited with code 1
  [warn] 20812#20812 failed to start application "myapp"
  [alert] 20812#20812 failed to apply new conf
Here's my minimal wsgi.py:
  # /var/www/myapp/wsgi.py
  import mypackage
  if __name__ == "__main__":
      mypackage.run()
The Flask application object is defined in mypackage.__init__.py:
  app = Flask(__name__)
NGINX Unit does not know about the virtual Python environment at this
time, and I don't know how I can set the required library paths. Can
somebody please point me in the right direction?
-Ralph
    
    
More information about the nginx
mailing list