diff options
| author | Hilko Bengen <bengen@debian.org> | 2014-06-07 12:02:12 +0200 |
|---|---|---|
| committer | Hilko Bengen <bengen@debian.org> | 2014-06-07 12:02:12 +0200 |
| commit | d5ed89b946297270ec28abf44bef2371a06f1f4f (patch) | |
| tree | ce2d945e4dde69af90bd9905a70d8d27f4936776 /bin | |
| download | elasticsearch-d5ed89b946297270ec28abf44bef2371a06f1f4f.tar.gz | |
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/elasticsearch | 214 | ||||
| -rw-r--r-- | bin/elasticsearch-service-mgr.exe | bin | 0 -> 104448 bytes | |||
| -rw-r--r-- | bin/elasticsearch-service-x64.exe | bin | 0 -> 103936 bytes | |||
| -rw-r--r-- | bin/elasticsearch-service-x86.exe | bin | 0 -> 80896 bytes | |||
| -rw-r--r-- | bin/elasticsearch.bat | 79 | ||||
| -rw-r--r-- | bin/elasticsearch.in.sh | 64 | ||||
| -rwxr-xr-x | bin/plugin | 49 | ||||
| -rw-r--r-- | bin/plugin.bat | 22 | ||||
| -rw-r--r-- | bin/service.bat | 231 |
9 files changed, 659 insertions, 0 deletions
diff --git a/bin/elasticsearch b/bin/elasticsearch new file mode 100755 index 0000000..e3eb514 --- /dev/null +++ b/bin/elasticsearch @@ -0,0 +1,214 @@ +#!/bin/sh + +# OPTIONS: +# -d: daemonize, start in the background +# -p <filename>: log the pid to a file (useful to kill it later) + +# CONTROLLING STARTUP: +# +# This script relies on few environment variables to determine startup +# behavior, those variables are: +# +# ES_CLASSPATH -- A Java classpath containing everything necessary to run. +# JAVA_OPTS -- Additional arguments to the JVM for heap size, etc +# ES_JAVA_OPTS -- External Java Opts on top of the defaults set +# +# +# Optionally, exact memory values can be set using the following values, note, +# they can still be set using the `ES_JAVA_OPTS`. Sample format include "512m", and "10g". +# +# ES_HEAP_SIZE -- Sets both the minimum and maximum memory to allocate (recommended) +# +# As a convenience, a fragment of shell is sourced in order to set one or +# more of these variables. This so-called `include' can be placed in a +# number of locations and will be searched for in order. The lowest +# priority search path is the same directory as the startup script, and +# since this is the location of the sample in the project tree, it should +# almost work Out Of The Box. +# +# Any serious use-case though will likely require customization of the +# include. For production installations, it is recommended that you copy +# the sample to one of /usr/share/elasticsearch/elasticsearch.in.sh, +# /usr/local/share/elasticsearch/elasticsearch.in.sh, or +# /opt/elasticsearch/elasticsearch.in.sh and make your modifications there. +# +# Another option is to specify the full path to the include file in the +# environment. For example: +# +# $ ES_INCLUDE=/path/to/in.sh elasticsearch -p /var/run/es.pid +# +# Note: This is particularly handy for running multiple instances on a +# single installation, or for quick tests. +# +# If you would rather configure startup entirely from the environment, you +# can disable the include by exporting an empty ES_INCLUDE, or by +# ensuring that no include files exist in the aforementioned search list. +# Be aware that you will be entirely responsible for populating the needed +# environment variables. + + +# Maven will replace the project.name with elasticsearch below. If that +# hasn't been done, we assume that this is not a packaged version and the +# user has forgotten to run Maven to create a package. +IS_PACKAGED_VERSION='${project.name}' +if [ "$IS_PACKAGED_VERSION" != "elasticsearch" ]; then + cat >&2 << EOF +Error: You must build the project with Maven or download a pre-built package +before you can run Elasticsearch. See 'Building from Source' in README.textile +or visit http://www.elasticsearch.org/download to get a pre-built package. +EOF + exit 1 +fi + +CDPATH="" +SCRIPT="$0" + +# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + # Drop everything prior to -> + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +# determine elasticsearch home +ES_HOME=`dirname "$SCRIPT"`/.. + +# make ELASTICSEARCH_HOME absolute +ES_HOME=`cd "$ES_HOME"; pwd` + + +# If an include wasn't specified in the environment, then search for one... +if [ "x$ES_INCLUDE" = "x" ]; then + # Locations (in order) to use when searching for an include file. + for include in /usr/share/elasticsearch/elasticsearch.in.sh \ + /usr/local/share/elasticsearch/elasticsearch.in.sh \ + /opt/elasticsearch/elasticsearch.in.sh \ + ~/.elasticsearch.in.sh \ + "`dirname "$0"`"/elasticsearch.in.sh; do + if [ -r "$include" ]; then + . "$include" + break + fi + done +# ...otherwise, source the specified include. +elif [ -r "$ES_INCLUDE" ]; then + . "$ES_INCLUDE" +fi + +if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA=`which java` +fi + +if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 +fi + +if [ -z "$ES_CLASSPATH" ]; then + echo "You must set the ES_CLASSPATH var" >&2 + exit 1 +fi + +# Special-case path variables. +case `uname` in + CYGWIN*) + ES_CLASSPATH=`cygpath -p -w "$ES_CLASSPATH"` + ES_HOME=`cygpath -p -w "$ES_HOME"` + ;; +esac + +launch_service() +{ + pidpath=$1 + daemonized=$2 + props=$3 + es_parms="-Delasticsearch" + + if [ "x$pidpath" != "x" ]; then + es_parms="$es_parms -Des.pidfile=$pidpath" + fi + + # The es-foreground option will tell Elasticsearch not to close stdout/stderr, but it's up to us not to daemonize. + if [ "x$daemonized" = "x" ]; then + es_parms="$es_parms -Des.foreground=yes" + exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \ + org.elasticsearch.bootstrap.Elasticsearch + # exec without running it in the background, makes it replace this shell, we'll never get here... + # no need to return something + else + # Startup Elasticsearch, background it, and write the pid. + exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \ + org.elasticsearch.bootstrap.Elasticsearch <&- & + return $? + fi +} + +# Parse any long getopt options and put them into properties before calling getopt below +# Be dash compatible to make sure running under ubuntu works +ARGV="" +while [ $# -gt 0 ] +do + case $1 in + --*=*) properties="$properties -Des.${1#--}" + shift 1 + ;; + --*) properties="$properties -Des.${1#--}=$2" + shift 2 + ;; + *) ARGV="$ARGV $1" ; shift + esac +done + +# Parse any command line options. +args=`getopt vdhp:D:X: $ARGV` +eval set -- "$args" + +while true; do + case $1 in + -v) + "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \ + org.elasticsearch.Version + exit 0 + ;; + -p) + pidfile="$2" + shift 2 + ;; + -d) + daemonized="yes" + shift + ;; + -h) + echo "Usage: $0 [-d] [-h] [-p pidfile]" + exit 0 + ;; + -D) + properties="$properties -D$2" + shift 2 + ;; + -X) + properties="$properties -X$2" + shift 2 + ;; + --) + shift + break + ;; + *) + echo "Error parsing argument $1!" >&2 + exit 1 + ;; + esac +done + +# Start up the service +launch_service "$pidfile" "$daemonized" "$properties" + +exit $? diff --git a/bin/elasticsearch-service-mgr.exe b/bin/elasticsearch-service-mgr.exe Binary files differnew file mode 100644 index 0000000..7302404 --- /dev/null +++ b/bin/elasticsearch-service-mgr.exe diff --git a/bin/elasticsearch-service-x64.exe b/bin/elasticsearch-service-x64.exe Binary files differnew file mode 100644 index 0000000..dab7def --- /dev/null +++ b/bin/elasticsearch-service-x64.exe diff --git a/bin/elasticsearch-service-x86.exe b/bin/elasticsearch-service-x86.exe Binary files differnew file mode 100644 index 0000000..4240720 --- /dev/null +++ b/bin/elasticsearch-service-x86.exe diff --git a/bin/elasticsearch.bat b/bin/elasticsearch.bat new file mode 100644 index 0000000..b9c1bbb --- /dev/null +++ b/bin/elasticsearch.bat @@ -0,0 +1,79 @@ +@echo off + +SETLOCAL + +if NOT DEFINED JAVA_HOME goto err + +set SCRIPT_DIR=%~dp0 +for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI + + +REM ***** JAVA options ***** + +if "%ES_MIN_MEM%" == "" ( +set ES_MIN_MEM=256m +) + +if "%ES_MAX_MEM%" == "" ( +set ES_MAX_MEM=1g +) + +if NOT "%ES_HEAP_SIZE%" == "" ( +set ES_MIN_MEM=%ES_HEAP_SIZE% +set ES_MAX_MEM=%ES_HEAP_SIZE% +) + +set JAVA_OPTS=%JAVA_OPTS% -Xms%ES_MIN_MEM% -Xmx%ES_MAX_MEM% + +if NOT "%ES_HEAP_NEWSIZE%" == "" ( +set JAVA_OPTS=%JAVA_OPTS% -Xmn%ES_HEAP_NEWSIZE% +) + +if NOT "%ES_DIRECT_SIZE%" == "" ( +set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=%ES_DIRECT_SIZE% +) + +set JAVA_OPTS=%JAVA_OPTS% -Xss256k + +REM Enable aggressive optimizations in the JVM +REM - Disabled by default as it might cause the JVM to crash +REM set JAVA_OPTS=%JAVA_OPTS% -XX:+AggressiveOpts + +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParNewGC +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseConcMarkSweepGC + +set JAVA_OPTS=%JAVA_OPTS% -XX:CMSInitiatingOccupancyFraction=75 +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseCMSInitiatingOccupancyOnly + +REM When running under Java 7 +REM JAVA_OPTS=%JAVA_OPTS% -XX:+UseCondCardMark + +REM GC logging options -- uncomment to enable +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime +REM JAVA_OPTS=%JAVA_OPTS% -Xloggc:/var/log/elasticsearch/gc.log + +REM Causes the JVM to dump its heap on OutOfMemory. +set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError +REM The path to the heap dump location, note directory must exists and have enough +REM space for a full heap dump. +REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof + +set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/${project.build.finalName}.jar;%ES_HOME%/lib/*;%ES_HOME%/lib/sigar/* +set ES_PARAMS=-Delasticsearch -Des-foreground=yes -Des.path.home="%ES_HOME%" + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% %ES_PARAMS% %* -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" +goto finally + + +:err +echo JAVA_HOME environment variable must be set! +pause + + +:finally + +ENDLOCAL diff --git a/bin/elasticsearch.in.sh b/bin/elasticsearch.in.sh new file mode 100644 index 0000000..8713205 --- /dev/null +++ b/bin/elasticsearch.in.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/* + +if [ "x$ES_MIN_MEM" = "x" ]; then + ES_MIN_MEM=256m +fi +if [ "x$ES_MAX_MEM" = "x" ]; then + ES_MAX_MEM=1g +fi +if [ "x$ES_HEAP_SIZE" != "x" ]; then + ES_MIN_MEM=$ES_HEAP_SIZE + ES_MAX_MEM=$ES_HEAP_SIZE +fi + +# min and max heap sizes should be set to the same value to avoid +# stop-the-world GC pauses during resize, and so that we can lock the +# heap in memory on startup to prevent any of it from being swapped +# out. +JAVA_OPTS="$JAVA_OPTS -Xms${ES_MIN_MEM}" +JAVA_OPTS="$JAVA_OPTS -Xmx${ES_MAX_MEM}" + +# new generation +if [ "x$ES_HEAP_NEWSIZE" != "x" ]; then + JAVA_OPTS="$JAVA_OPTS -Xmn${ES_HEAP_NEWSIZE}" +fi + +# max direct memory +if [ "x$ES_DIRECT_SIZE" != "x" ]; then + JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=${ES_DIRECT_SIZE}" +fi + +# reduce the per-thread stack size +JAVA_OPTS="$JAVA_OPTS -Xss256k" + +# set to headless, just in case +JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true" + +# Force the JVM to use IPv4 stack +if [ "x$ES_USE_IPV4" != "x" ]; then + JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true" +fi + +JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC" +JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC" + +JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75" +JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly" + +# GC logging options +if [ "x$ES_USE_GC_LOGGING" != "x" ]; then + JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails" + JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps" + JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram" + JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution" + JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime" + JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/elasticsearch/gc.log" +fi + +# Causes the JVM to dump its heap on OutOfMemory. +JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" +# The path to the heap dump location, note directory must exists and have enough +# space for a full heap dump. +#JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof" diff --git a/bin/plugin b/bin/plugin new file mode 100755 index 0000000..1cabad2 --- /dev/null +++ b/bin/plugin @@ -0,0 +1,49 @@ +#!/bin/sh + +CDPATH="" +SCRIPT="$0" + +# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + # Drop everything prior to -> + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +# determine elasticsearch home +ES_HOME=`dirname "$SCRIPT"`/.. + +# make ELASTICSEARCH_HOME absolute +ES_HOME=`cd "$ES_HOME"; pwd` + + +if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA=$JAVA_HOME/bin/java +else + JAVA=`which java` +fi + +# 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 + diff --git a/bin/plugin.bat b/bin/plugin.bat new file mode 100644 index 0000000..9946fa3 --- /dev/null +++ b/bin/plugin.bat @@ -0,0 +1,22 @@ +@echo off + +SETLOCAL + +if NOT DEFINED JAVA_HOME goto err + +set SCRIPT_DIR=%~dp0 +for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI + + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% -Xmx64m -Xms16m -Des.path.home="%ES_HOME%" -cp "%ES_HOME%/lib/*;" "org.elasticsearch.plugins.PluginManager" %* +goto finally + + +:err +echo JAVA_HOME environment variable must be set! +pause + + +:finally + +ENDLOCAL diff --git a/bin/service.bat b/bin/service.bat new file mode 100644 index 0000000..166f40a --- /dev/null +++ b/bin/service.bat @@ -0,0 +1,231 @@ +@echo off +SETLOCAL + +if NOT DEFINED JAVA_HOME goto err + +set SCRIPT_DIR=%~dp0 +for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI + +rem Detect JVM version to figure out appropriate executable to use +if not exist "%JAVA_HOME%\bin\java.exe" ( +echo JAVA_HOME points to an invalid Java installation (no java.exe found in "%JAVA_HOME%"^). Existing... +goto:eof +) +"%JAVA_HOME%\bin\java" -version 2>&1 | find "64-Bit" >nul: + +if errorlevel 1 goto x86 +set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe +set SERVICE_ID=elasticsearch-service-x64 +set ARCH=64-bit +goto checkExe + +:x86 +set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x86.exe +set SERVICE_ID=elasticsearch-service-x86 +set ARCH=32-bit + +:checkExe +if EXIST "%EXECUTABLE%" goto okExe +echo elasticsearch-service-(x86|x64).exe was not found... + +:okExe +set ES_VERSION=${project.version} + +if "%LOG_DIR%" == "" set LOG_DIR=%ES_HOME%\logs + +if "x%1x" == "xx" goto displayUsage +set SERVICE_CMD=%1 +shift +if "x%1x" == "xx" goto checkServiceCmd +set SERVICE_ID=%1 + +:checkServiceCmd + +if "%LOG_OPTS%" == "" set LOG_OPTS=--LogPath "%LOG_DIR%" --LogPrefix "%SERVICE_ID%" --StdError auto --StdOutput auto + +if /i %SERVICE_CMD% == install goto doInstall +if /i %SERVICE_CMD% == remove goto doRemove +if /i %SERVICE_CMD% == start goto doStart +if /i %SERVICE_CMD% == stop goto doStop +if /i %SERVICE_CMD% == manager goto doManagment +echo Unknown option "%SERVICE_CMD%" + +:displayUsage +echo. +echo Usage: service.bat install^|remove^|start^|stop^|manager [SERVICE_ID] +goto:eof + +:doStart +"%EXECUTABLE%" //ES//%SERVICE_ID% %LOG_OPTS% +if not errorlevel 1 goto started +echo Failed starting '%SERVICE_ID%' service +goto:eof +:started +echo The service '%SERVICE_ID%' has been started +goto:eof + +:doStop +"%EXECUTABLE%" //SS//%SERVICE_ID% %LOG_OPTS% +if not errorlevel 1 goto stopped +echo Failed stopping '%SERVICE_ID%' service +goto:eof +:stopped +echo The service '%SERVICE_ID%' has been stopped +goto:eof + +:doManagment +set EXECUTABLE_MGR=%ES_HOME%\bin\elasticsearch-service-mgr.exe +"%EXECUTABLE_MGR%" //ES//%SERVICE_ID% +if not errorlevel 1 goto managed +echo Failed starting service manager for '%SERVICE_ID%' +goto:eof +:managed +echo Succesfully started service manager for '%SERVICE_ID%'. +goto:eof + +:doRemove +rem Remove the service +"%EXECUTABLE%" //DS//%SERVICE_ID% %LOG_OPTS% +if not errorlevel 1 goto removed +echo Failed removing '%SERVICE_ID%' service +goto:eof +:removed +echo The service '%SERVICE_ID%' has been removed +goto:eof + +:doInstall +echo Installing service : "%SERVICE_ID%" +echo Using JAVA_HOME (%ARCH%): "%JAVA_HOME%" + +rem Check JVM server dll first +set JVM_DLL=%JAVA_HOME%\jre\bin\server\jvm.dll +if exist "%JVM_DLL%" goto foundJVM + +rem Check 'server' JRE (JRE installed on Windows Server) +set JVM_DLL=%JAVA_HOME%\bin\server\jvm.dll +if exist "%JVM_DLL%" goto foundJVM + +rem Fallback to 'client' JRE +set JVM_DLL=%JAVA_HOME%\bin\client\jvm.dll + +if exist "%JVM_DLL%" ( +echo Warning: JAVA_HOME points to a JRE and not JDK installation; a client (not a server^) JVM will be used... +) else ( +echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Existing... +goto:eof +) + +:foundJVM +if "%ES_MIN_MEM%" == "" set ES_MIN_MEM=256m +if "%ES_MAX_MEM%" == "" set ES_MAX_MEM=1g + +if NOT "%ES_HEAP_SIZE%" == "" set ES_MIN_MEM=%ES_HEAP_SIZE% +if NOT "%ES_HEAP_SIZE%" == "" set ES_MAX_MEM=%ES_HEAP_SIZE% + +call:convertxm %ES_MIN_MEM% JVM_XMS +call:convertxm %ES_MAX_MEM% JVM_XMX + +rem java_opts might be empty - init to avoid tripping commons daemon (if the command starts with ;) +if not "%JAVA_OPTS%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParNewGC +if "%JAVA_OPTS%" == "" set JAVA_OPTS=-XX:+UseParNewGC + +if NOT "%ES_HEAP_NEWSIZE%" == "" set JAVA_OPTS=%JAVA_OPTS% -Xmn%ES_HEAP_NEWSIZE% + +if NOT "%ES_DIRECT_SIZE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=%ES_DIRECT_SIZE% + +rem thread stack size +set JVM_SS=256 + +REM Enable aggressive optimizations in the JVM +REM - Disabled by default as it might cause the JVM to crash +REM set JAVA_OPTS=%JAVA_OPTS% -XX:+AggressiveOpts + + +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseConcMarkSweepGC + +set JAVA_OPTS=%JAVA_OPTS% -XX:CMSInitiatingOccupancyFraction=75 +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseCMSInitiatingOccupancyOnly + +REM GC logging options -- uncomment to enable +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution +REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime +REM JAVA_OPTS=%JAVA_OPTS% -Xloggc:/var/log/elasticsearch/gc.log + +REM Causes the JVM to dump its heap on OutOfMemory. +set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError +REM The path to the heap dump location, note directory must exists and have enough +REM space for a full heap dump. +REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof + +if "%DATA_DIR%" == "" set DATA_DIR=%ES_HOME%\data + +if "%WORK_DIR%" == "" set WORK_DIR=%ES_HOME% + +if "%CONF_DIR%" == "" set CONF_DIR=%ES_HOME%\config + +if "%CONF_FILE%" == "" set CONF_FILE=%ES_HOME%\config\elasticsearch.yml + +set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/elasticsearch-%ES_VERSION%.jar;%ES_HOME%/lib/*;%ES_HOME%/lib/sigar/* +set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.default.config="%CONF_FILE%";-Des.default.path.home="%ES_HOME%";-Des.default.path.logs="%LOG_DIR%";-Des.default.path.data="%DATA_DIR%";-Des.default.path.work="%WORK_DIR%";-Des.default.path.conf="%CONF_DIR%" + +set JVM_OPTS=%JAVA_OPTS: =;% + +if not "%ES_JAVA_OPTS%" == "" set JVM_ES_JAVA_OPTS=%ES_JAVA_OPTS: =#% +if not "%ES_JAVA_OPTS%" == "" set JVM_OPTS=%JVM_OPTS%;%JVM_ES_JAVA_OPTS% + +if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual +if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0 + +"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.Elasticsearch --StopClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmSs %JVM_SS% --JvmMs %JVM_XMS% --JvmMx %JVM_XMX% --JvmOptions %JVM_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "Elasticsearch %ES_VERSION% (%SERVICE_ID%)" --Description "Elasticsearch %ES_VERSION% Windows Service - http://elasticsearch.org" --Jvm "%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" + + +if not errorlevel 1 goto installed +echo Failed installing '%SERVICE_ID%' service +goto:eof + +:installed +echo The service '%SERVICE_ID%' has been installed. +goto:eof + +:err +echo JAVA_HOME environment variable must be set! +pause + +goto:eof + +rem --- +rem Function for converting Xm[s|x] values into MB which Commons Daemon accepts +rem --- +:convertxm +set value=%~1 +rem extract last char (unit) +set unit=%value:~-1% +rem assume the unit is specified +set conv=%value:~0,-1% + +if "%unit%" == "k" goto kilo +if "%unit%" == "K" goto kilo +if "%unit%" == "m" goto mega +if "%unit%" == "M" goto mega +if "%unit%" == "g" goto giga +if "%unit%" == "G" goto giga + +rem no unit found, must be bytes; consider the whole value +set conv=%value% +rem convert to KB +set /a conv=%conv% / 1024 +:kilo +rem convert to MB +set /a conv=%conv% / 1024 +goto mega +:giga +rem convert to MB +set /a conv=%conv% * 1024 +:mega +set "%~2=%conv%" +goto:eof + +ENDLOCAL |
