use symlinks to automagically load plugins

This commit is contained in:
roberto@mrspurr
2010-11-12 04:08:50 +01:00
parent 3e7992d0ac
commit 373c45c7d4
2 changed files with 25 additions and 5 deletions
+11
View File
@@ -455,6 +455,17 @@ int main(int argc, char *argv[], char *envp[])
//initialize embedded plugins
UWSGI_LOAD_EMBEDDED_PLUGINS
// 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;
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);
plugins_requested = getenv("UWSGI_PLUGINS");
if (plugins_requested) {
char *p = strtok(plugins_requested, ",");
+14 -5
View File
@@ -312,7 +312,7 @@ class uConf():
return self.gcc_list, self.cflags, self.ldflags, self.libs
def build_plugin(path, uc, cflags, ldflags, libs):
def build_plugin(path, uc, cflags, ldflags, libs, name = None):
path = path.rstrip('/')
sys.path.insert(0, path)
@@ -329,7 +329,12 @@ def build_plugin(path, uc, cflags, ldflags, libs):
p_cflags.insert(0, '-I.')
plugin_dest = uc.get('plugin_dir') + '/' + up.NAME + '_plugin'
if name is None:
name = up.NAME
else:
p_cflags.append("-D%s_plugin=%s_plugin" % (up.NAME, name))
plugin_dest = uc.get('plugin_dir') + '/' + name + '_plugin'
shared_flag = '-shared'
@@ -347,10 +352,10 @@ def build_plugin(path, uc, cflags, ldflags, libs):
ret = os.system(gccline)
if ret != 0:
print("*** unable to build %s plugin ***" % up.NAME)
print("*** unable to build %s plugin ***" % name)
sys.exit(1)
print("*** %s plugin built and available in %s ***" % (up.NAME, plugin_dest + '.so'))
print("*** %s plugin built and available in %s ***" % (name, plugin_dest + '.so'))
if __name__ == "__main__":
try:
@@ -387,7 +392,11 @@ if __name__ == "__main__":
uc = uConf('buildconf/%s' % bconf)
gcc_list, cflags, ldflags, libs = uc.get_gcll()
build_plugin(sys.argv[2], uc, cflags, ldflags, libs)
try:
name = sys.argv[4]
except:
name = None
build_plugin(sys.argv[2], uc, cflags, ldflags, libs, name)
else:
print("unknown uwsgiconfig command")
sys.exit(1)