Welcome! Log In Create A New Profile

Advanced

Flask app with virtual Python environment in Unit 1.1 ?

Ralph Seichter
April 29, 2018 10:12AM
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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Flask app with virtual Python environment in Unit 1.1 ?

Ralph Seichter April 29, 2018 10:12AM

Re: Flask app with virtual Python environment in Unit 1.1 ?

Valentin V. Bartenev April 29, 2018 11:08AM

Re: Flask app with virtual Python environment in Unit 1.1 ?

Ralph Seichter April 29, 2018 12:04PM

Re: Flask app with virtual Python environment in Unit 1.1 ?

Valentin V. Bartenev April 29, 2018 05:04PM

Re: Flask app with virtual Python environment in Unit 1.1 ?

Ralph Seichter April 30, 2018 05:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 57
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready