Skip to content

Allow bin/plugin to set -D JVM parameters #3339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion bin/plugin
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,23 @@ else
JAVA=`which java`
fi

exec $JAVA $JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $*
# this is a poor mans getopt replacement
# real getopt cannot be used because we need to hand options over to the PluginManager
while [ $# -gt 0 ]; do
case $1 in
-D*=*)
properties="$properties $1"
;;
-D*)
var=$1
shift
properties="$properties $var=$1"
;;
*)
args="$args $1"
esac
shift
done

exec $JAVA $JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args

7 changes: 4 additions & 3 deletions src/main/java/org/elasticsearch/plugins/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void downloadAndExtract(String name, boolean verbose) throws IOException
// extract the plugin
File extractLocation = new File(environment.pluginsFile(), name);
if (extractLocation.exists()) {
throw new IOException("plugin directory already exists. To update the plugin, uninstall it first using -remove " + name + " command");
throw new IOException("plugin directory " + extractLocation.getAbsolutePath() + " already exists. To update the plugin, uninstall it first using -remove " + name + " command");
}
ZipFile zipFile = null;
try {
Expand All @@ -235,6 +235,7 @@ public void downloadAndExtract(String name, boolean verbose) throws IOException
FileSystemUtils.mkdirs(target.getParentFile());
Streams.copy(zipFile.getInputStream(zipEntry), new FileOutputStream(target));
}
System.out.println("Installed " + name + " into " + extractLocation.getAbsolutePath());
} catch (Exception e) {
System.err.println("failed to extract plugin [" + pluginFile + "]: " + ExceptionsHelper.detailedMessage(e));
return;
Expand All @@ -261,6 +262,7 @@ public void downloadAndExtract(String name, boolean verbose) throws IOException
System.out.println("Found bin, moving to " + toLocation.getAbsolutePath());
FileSystemUtils.deleteRecursively(toLocation);
binFile.renameTo(toLocation);
System.out.println("Installed " + name + " into " + toLocation.getAbsolutePath());
}

// try and identify the plugin type, see if it has no .class or .jar files in it
Expand All @@ -273,10 +275,9 @@ public void downloadAndExtract(String name, boolean verbose) throws IOException
extractLocation.renameTo(tmpLocation);
FileSystemUtils.mkdirs(extractLocation);
tmpLocation.renameTo(site);
System.out.println("Installed " + name + " into " + site.getAbsolutePath());
}
}

System.out.println("Installed " + name);
}

public void removePlugin(String name) throws IOException {
Expand Down