diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index ce927c35..f18bcc8e 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -114,7 +114,6 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre uwsgi_log("%s = %s\n", PyString_AsString(k), PyString_AsString(env_value)); if (PyObject_SetItem(py_environ, k, env_value)) { - uwsgi_log("cazzo\n"); PyErr_Print(); } @@ -521,6 +520,9 @@ PyObject *uwsgi_file_loader(void *arg1) { PyObject *wsgi_file_module, *wsgi_file_dict; PyObject *wsgi_file_callable; + char *callable = up.callable; + if (!callable) callable = "application"; + wsgi_file_module = uwsgi_pyimport_by_filename("uwsgi_wsgi_file", filename); // no need to check here for module import as it is already done by uwsgi_pyimport_by_file @@ -530,7 +532,7 @@ PyObject *uwsgi_file_loader(void *arg1) { exit(1); } - wsgi_file_callable = PyDict_GetItemString(wsgi_file_dict, "application"); + wsgi_file_callable = PyDict_GetItemString(wsgi_file_dict, callable); if (!wsgi_file_callable) { PyErr_Print(); uwsgi_log( "unable to find \"application\" callable in file %s\n", filename); diff --git a/uwsgi.c b/uwsgi.c index 3a795b8b..977ba761 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -3796,7 +3796,8 @@ void uwsgi_init_all_apps() { } // no app initialized and virtualhosting enabled - if (uwsgi.apps_cnt == 0 && uwsgi.vhost) { + if (uwsgi.apps_cnt == 0) { + uwsgi_log("*** no app loaded. going in full dynamic mode ***\n"); uwsgi.apps_cnt = 1; } diff --git a/vhosttest/flask001/app1.py b/vhosttest/flask001/app1.py new file mode 100644 index 00000000..bbf7e467 --- /dev/null +++ b/vhosttest/flask001/app1.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello World!" diff --git a/vhosttest/flask002/app2.py b/vhosttest/flask002/app2.py new file mode 100644 index 00000000..346eca47 --- /dev/null +++ b/vhosttest/flask002/app2.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello World! app2 !!!" diff --git a/vhosttest/flask003/app3.py b/vhosttest/flask003/app3.py new file mode 100644 index 00000000..9e33a753 --- /dev/null +++ b/vhosttest/flask003/app3.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello World! app3" diff --git a/vhosttest/flask004/app4.py b/vhosttest/flask004/app4.py new file mode 100644 index 00000000..313aa7a3 --- /dev/null +++ b/vhosttest/flask004/app4.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello World! app4" diff --git a/vhosttest/flask005/app5.py b/vhosttest/flask005/app5.py new file mode 100644 index 00000000..54f51c34 --- /dev/null +++ b/vhosttest/flask005/app5.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello World! app5" diff --git a/vhosttest/nginx.conf b/vhosttest/nginx.conf new file mode 100644 index 00000000..cf630083 --- /dev/null +++ b/vhosttest/nginx.conf @@ -0,0 +1,49 @@ + +worker_processes 1; + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + + keepalive_timeout 65; + + gzip on; + + upstream uwsgi_server { + server 127.0.0.1:3031; + } + + include uwsgi_params; + uwsgi_param UWSGI_FILE $app; + uwsgi_param UWSGI_PYHOME $virtualenv; + + + server { + listen 8026; + server_name flask001; + set $app vhosttest/flask001/app1.py; + set $virtualenv vhosttest/venv001; + location / { + uwsgi_pass uwsgi_server; + } + } + + server { + listen 8026; + server_name flask002; + set $app vhosttest/flask002/app2.py; + set $virtualenv vhosttest/venv001; + location / { + uwsgi_pass uwsgi_server; + } + } + + +}