support for --mount option

This commit is contained in:
roberto@maverick64
2011-01-06 11:38:07 +01:00
parent 0a2da2a2ce
commit d57ddff924
9 changed files with 55 additions and 27 deletions
+3 -3
View File
@@ -51,7 +51,7 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, int ne
mountpoint = uwsgi_strncopy(wsgi_req->script_name, wsgi_req->script_name_len);
}
if (uwsgi_get_app_id(mountpoint, strlen(mountpoint)) != -1) {
if (uwsgi_get_app_id(mountpoint, strlen(mountpoint), -1) != -1) {
uwsgi_log( "mountpoint %.*s already configured. skip.\n", strlen(mountpoint), mountpoint);
free(mountpoint);
return -1;
@@ -350,7 +350,7 @@ PyObject *uwsgi_mount_loader(void *arg1) {
PyObject *callable = NULL;
char *what = (char *) arg1;
if ( !strcmp(what+strlen(what)-3, ".py") || !strcmp(what+strlen(what)-3, ".wsgi")) {
if ( !strcmp(what+strlen(what)-3, ".py") || !strcmp(what+strlen(what)-5, ".wsgi")) {
callable = uwsgi_file_loader((void *)what);
}
#ifdef UWSGI_PASTE
@@ -358,7 +358,7 @@ PyObject *uwsgi_mount_loader(void *arg1) {
callable = uwsgi_paste_loader((void *)what);
}
#endif
else {
else if (strchr(what, ':')) {
callable = uwsgi_uwsgi_loader((void *)what);
}
+13 -2
View File
@@ -751,7 +751,15 @@ int uwsgi_python_magic(char *mountpoint, char *lazy) {
return 0;
}
void uwsgi_python_init_app() {
int uwsgi_python_mount_app(char *mountpoint, char *app) {
uwsgi.wsgi_req->script_name = mountpoint;
uwsgi.wsgi_req->script_name_len = strlen(mountpoint);
return init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, uwsgi.single_interpreter-1);
}
void uwsgi_python_init_apps() {
if (up.wsgi_config != NULL) {
init_uwsgi_app(LOADER_UWSGI, up.wsgi_config, uwsgi.wsgi_req, 0);
@@ -919,7 +927,10 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
.short_options = "w:O:H:j:",
.request = uwsgi_request_wsgi,
.after_request = uwsgi_after_request_wsgi,
.init_apps = uwsgi_python_init_app,
.init_apps = uwsgi_python_init_apps,
.mount_app = uwsgi_python_mount_app,
.enable_threads = uwsgi_python_enable_threads,
.init_thread = uwsgi_python_init_thread,
.manage_xml = uwsgi_python_xml,
+11
View File
@@ -56,6 +56,17 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
#define UWSGI_PYFROMSTRINGSIZE(x, y) PyString_FromStringAndSize(x, y)
#endif
#define LOADER_DYN 0
#define LOADER_UWSGI 1
#define LOADER_FILE 2
#define LOADER_PASTE 3
#define LOADER_EVAL 4
#define LOADER_CALLABLE 5
#define LOADER_STRING_CALLABLE 6
#define LOADER_MOUNT 7
#define LOADER_MAX 8
struct uwsgi_python {
char *home;
+1 -1
View File
@@ -136,7 +136,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
}
if ( (wsgi_req->app_id = uwsgi_get_app_id(what, what_len)) == -1) {
if ( (wsgi_req->app_id = uwsgi_get_app_id(what, what_len, 0)) == -1) {
if (wsgi_req->script_name_len > 1 || uwsgi.default_app < 0 || uwsgi.vhost) {
/* unavailable app for this SCRIPT_NAME */
wsgi_req->app_id = -1;