diff --git a/buildconf/unbit.ini b/buildconf/unbit.ini new file mode 100644 index 00000000..d4da1320 --- /dev/null +++ b/buildconf/unbit.ini @@ -0,0 +1,28 @@ +[uwsgi] +xml = true +ini = true +snmp = false +sctp = false +erlang = false +spooler = true +embedded = true +udp = false +multicast = false +threading = true +sendfile = true +nagios = false +proxy = false +minterpreters = true +async = true +http = false +evdis = false +ldap = false +routing = false +stackless = false +debug = false +unbit = true +xml_implementation = libxml2 +plugins = +bin_name = /opt/unbit/bin/uwsgi +plugin_dir = /opt/unbit/uwsgi_plugins +embedded_plugins = diff --git a/master.c b/master.c index 6579068c..f5d72e87 100644 --- a/master.c +++ b/master.c @@ -100,7 +100,7 @@ void master_loop(char **argv, char **environ) { #endif for (;;) { - uwsgi_log("ready_to_reload %d %d\n", ready_to_reload, uwsgi.numproc); + //uwsgi_log("ready_to_reload %d %d\n", ready_to_reload, uwsgi.numproc); if (ready_to_die >= uwsgi.numproc && uwsgi.to_hell) { #ifdef UWSGI_SPOOLER if (uwsgi.spool_dir && uwsgi.shared->spooler_pid > 0) { diff --git a/plugins.c b/plugins.c index eb956097..1bbee0f1 100644 --- a/plugins.c +++ b/plugins.c @@ -46,7 +46,12 @@ int uwsgi_load_plugin(int modifier, char *plugin, char *pargs, int absolute) { plugin_entry_symbol = uwsgi_concat2(plugin, "_plugin"); up = dlsym(plugin_handle, plugin_entry_symbol); if (up) { - fill_plugin_table(up->modifier1, up); + if (modifier != -1) { + fill_plugin_table(modifier, up); + } + else { + fill_plugin_table(up->modifier1, up); + } return 1; } uwsgi_log( "%s\n", dlerror()); diff --git a/plugins/python/uwsgiplugin.py b/plugins/python/uwsgiplugin.py index 4e2174e1..cc0512ef 100644 --- a/plugins/python/uwsgiplugin.py +++ b/plugins/python/uwsgiplugin.py @@ -11,6 +11,10 @@ LDFLAGS = [] LIBS = sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split() if not sysconfig.get_config_var('Py_ENABLE_SHARED'): LIBS.append('-L' + sysconfig.get_config_var('LIBPL')) +else: + LDFLAGS.append("-L%s/lib" % sysconfig.PREFIX) + os.environ['LD_RUN_PATH'] = "%s/lib" % sysconfig.PREFIX + version = sys.version_info uver = "%d.%d" % (version[0], version[1]) diff --git a/plugins/rack/rack_plugin.c b/plugins/rack/rack_plugin.c index 975f72f2..c6b20319 100644 --- a/plugins/rack/rack_plugin.c +++ b/plugins/rack/rack_plugin.c @@ -328,7 +328,7 @@ VALUE require_rails(VALUE arg) { #endif } -VALUE init_rack_app(char *); +VALUE init_rack_app(VALUE); int uwsgi_rack_init(){ @@ -364,7 +364,11 @@ int uwsgi_rack_init(){ #endif if (ur.rack) { - ur.dispatcher = init_rack_app(ur.rack); + ur.dispatcher = rb_protect(init_rack_app, rb_str_new2(ur.rack), &error); + if (error) { + uwsgi_ruby_exception(); + exit(1); + } if (ur.dispatcher == Qnil) { exit(1); } @@ -487,7 +491,11 @@ VALUE send_header(VALUE obj, VALUE headers) { } else if (TYPE(obj) == T_STRING) { hkey = obj; +#ifdef RUBY19 hval = rb_hash_lookup(headers, obj); +#else + hval = rb_hash_aref(headers, obj); +#endif } else { goto clear; @@ -756,7 +764,7 @@ void uwsgi_rack_init_thread(int core_id) { // thread initialization } -VALUE init_rack_app( char *script ) { +VALUE init_rack_app( VALUE script ) { int error; @@ -770,14 +778,14 @@ VALUE init_rack_app( char *script ) { } VALUE rack = rb_const_get(rb_cObject, rb_intern("Rack")); - VALUE rackup = rb_funcall( rb_const_get(rack, rb_intern("Builder")), rb_intern("parse_file"), 1, rb_str_new2(script)); + VALUE rackup = rb_funcall( rb_const_get(rack, rb_intern("Builder")), rb_intern("parse_file"), 1, script); if (TYPE(rackup) != T_ARRAY) { - uwsgi_log("unable to parse %s file\n", script); + uwsgi_log("unable to parse %s file\n", RSTRING(script)->ptr); return Qnil; } if (RARRAY_LEN(rackup) < 1) { - uwsgi_log("invalid rack config file: %s\n", script); + uwsgi_log("invalid rack config file: %s\n", RSTRING(script)->ptr); return Qnil; } @@ -786,8 +794,10 @@ VALUE init_rack_app( char *script ) { int uwsgi_rack_xml(char *node, char *content) { + int error; + if (!strcmp("rack", node)) { - ur.dispatcher = init_rack_app(content); + ur.dispatcher = rb_protect(init_rack_app, rb_str_new2(content), &error); if (ur.dispatcher != Qnil) { rb_gc_register_address(&ur.dispatcher); uwsgi_log("Rack application ready\n"); diff --git a/plugins/rack/uwsgiplugin.py b/plugins/rack/uwsgiplugin.py index 68e4083d..6d8f8dec 100644 --- a/plugins/rack/uwsgiplugin.py +++ b/plugins/rack/uwsgiplugin.py @@ -2,7 +2,11 @@ import os,sys NAME='rack' -RUBYPATH = 'ruby' +try: + RUBYPATH = os.environ['UWSGICONFIG_RUBYPATH'] +except: + RUBYPATH = 'ruby' + CFLAGS = os.popen(RUBYPATH + " -e \"require 'rbconfig';print Config::CONFIG['CFLAGS']\"").read().rstrip().split() version = os.popen(RUBYPATH + " -e \"print RUBY_VERSION\"").read().rstrip() diff --git a/uwsgi.c b/uwsgi.c index 23ffb4b3..1b666a5c 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -458,19 +458,22 @@ int main(int argc, char *argv[], char *envp[]) // now a bit of magic, if the argv[0] contains a _ try to automatically load a plugin uwsgi_log("executable name: %s\n", argv[0]); char *p = strtok(argv[0], "_"); - plugins_requested = p; + plugins_requested = NULL; while (p != NULL) { p = strtok(NULL, "_"); if (p) plugins_requested = p; } - uwsgi_log("plugin = %s\n", plugins_requested); - uwsgi_load_plugin(0, plugins_requested, NULL, 0); + + if (plugins_requested) { + uwsgi_log("plugin = %s\n", plugins_requested); + uwsgi_load_plugin(0, plugins_requested, NULL, 0); + } plugins_requested = getenv("UWSGI_PLUGINS"); if (plugins_requested) { char *p = strtok(plugins_requested, ","); while (p != NULL) { - uwsgi_load_plugin(0, p, NULL, 0); + uwsgi_load_plugin(-1, p, NULL, 0); p = strtok(NULL, ","); } } @@ -1436,7 +1439,7 @@ end: #ifdef UWSGI_DEBUG uwsgi_debug("loading plugin %s\n", p); #endif - uwsgi_load_plugin(0, p, NULL, 0); + uwsgi_load_plugin(-1, p, NULL, 0); p = strtok(NULL, ","); } build_options();