diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index 073a9805..e105ff9c 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -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); } diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 4cbe33c0..db7ca886 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -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, diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index b4cfa17d..5ac8e47b 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -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; diff --git a/plugins/python/wsgi_handlers.c b/plugins/python/wsgi_handlers.c index a7386c40..809e0309 100644 --- a/plugins/python/wsgi_handlers.c +++ b/plugins/python/wsgi_handlers.c @@ -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; diff --git a/plugins/rack/rack_plugin.c b/plugins/rack/rack_plugin.c index dfc12d17..56101cb1 100644 --- a/plugins/rack/rack_plugin.c +++ b/plugins/rack/rack_plugin.c @@ -792,6 +792,18 @@ int uwsgi_rack_magic(char *mountpoint, char *lazy) { return 0; } +/* +int uwsgi_rack_mount_app(char *mountpoint, char *app) { + + + if ( !strcmp(what+strlen(what)-3, ".ru") || !strcmp(what+strlen(what)-3, ".rb")) { + return = uwsgi_rack_load(mountpoint, what); + } + + return -1; +} +*/ + struct uwsgi_plugin rack_plugin = { .name = "rack", @@ -802,6 +814,7 @@ struct uwsgi_plugin rack_plugin = { .request = uwsgi_rack_request, .after_request = uwsgi_rack_after_request, + //.mount_app = uwsgi_rack_mount_app, .manage_xml = uwsgi_rack_xml, .magic = uwsgi_rack_magic, diff --git a/utils.c b/utils.c index 32d675cc..cffcdeca 100644 --- a/utils.c +++ b/utils.c @@ -922,7 +922,7 @@ char *uwsgi_strncopy(char *s, int len) { } -int uwsgi_get_app_id(char *script_name, int script_name_len) { +int uwsgi_get_app_id(char *script_name, int script_name_len, int modifier1) { int i; @@ -931,7 +931,8 @@ int uwsgi_get_app_id(char *script_name, int script_name_len) { continue; } if (!uwsgi_strncmp(uwsgi.apps[i].mountpoint, uwsgi.apps[i].mountpoint_len, script_name, script_name_len)) { - return i; + if (modifier1 == -1) return i; + if (modifier1 == uwsgi.apps[i].modifier1) return i; } } diff --git a/uwsgi.c b/uwsgi.c index 4f3e4c8f..48a5f122 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -515,7 +515,7 @@ int main(int argc, char *argv[], char *envp[]) } #endif // manage magic mountpoint - else if (lazy[0] == '/' && strchr(lazy,'=')) { + else if ( (lazy[0] == '/' || strchr(lazy, '|')) && strchr(lazy,'=')) { } else { int magic = 0; @@ -1382,9 +1382,13 @@ uwsgi.shared->hooks[UWSGI_MODIFIER_PING] = uwsgi_request_ping; //100 if (what) { what[0] = 0; what++; - uwsgi.wsgi_req->script_name = uwsgi.mounts[i]; - uwsgi.wsgi_req->script_name_len = strlen(uwsgi.mounts[i]); - //init_uwsgi_app(LOADER_MOUNT, what, uwsgi.wsgi_req, 0); + uwsgi_log("mounting %s on %s\n", what, uwsgi.mounts[i]); + for (j = 0; j < 0xFF; j++) { + if (uwsgi.p[j]->mount_app) { + if (uwsgi.p[j]->mount_app(uwsgi.mounts[i], what) != -1) break; + } + } + what--; what[0] = '='; } else { uwsgi_log("invalid mountpoint: %s\n", uwsgi.mounts[i]); exit(1); diff --git a/uwsgi.h b/uwsgi.h index dbde1bb6..849c48fc 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -389,6 +389,7 @@ struct uwsgi_plugin { int (*request) (struct wsgi_request *); void (*after_request) (struct wsgi_request *); void (*init_apps) (void); + int (*mount_app) (char *, char *); int (*manage_udp) (char *, int, char *, int); int (*manage_xml) (char *, char *); void (*suspend) (struct wsgi_request *); @@ -413,8 +414,6 @@ struct uwsgi_app { int mountpoint_len; void *interpreter; - //PyObject * pymain_dict; - //PyObject * wsgi_dict; void *callable; @@ -587,17 +586,6 @@ struct wsgi_request { int leave_open; }; -#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_fmon { char filename[0xff]; int fd; @@ -1262,7 +1250,7 @@ char *uwsgi_concat4(char *, char *, char *, char *); char *uwsgi_concat4n(char *, int, char *, int, char *, int, char *, int); -int uwsgi_get_app_id(char *, int); +int uwsgi_get_app_id(char *, int, int); char *uwsgi_strncopy(char *, int); void master_loop(char **, char **); diff --git a/uwsgicc/templates/index.html b/uwsgicc/templates/index.html index 11ce630d..f78dd8df 100644 --- a/uwsgicc/templates/index.html +++ b/uwsgicc/templates/index.html @@ -228,7 +228,7 @@ $(document).ready(function() {