fluent-plugin-embedded-elasticsearch 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +46 -0
  3. data/conf/example.conf +32 -0
  4. data/lib/fluent/plugin/in_embedded_elasticsearch.rb +52 -0
  5. data/vendor/elasticsearch/LICENSE.txt +202 -0
  6. data/vendor/elasticsearch/NOTICE.txt +5 -0
  7. data/vendor/elasticsearch/README.textile +227 -0
  8. data/vendor/elasticsearch/bin/elasticsearch +184 -0
  9. data/vendor/elasticsearch/bin/elasticsearch-service-mgr.exe +0 -0
  10. data/vendor/elasticsearch/bin/elasticsearch-service-x64.exe +0 -0
  11. data/vendor/elasticsearch/bin/elasticsearch-service-x86.exe +0 -0
  12. data/vendor/elasticsearch/bin/elasticsearch.bat +79 -0
  13. data/vendor/elasticsearch/bin/elasticsearch.in.sh +64 -0
  14. data/vendor/elasticsearch/bin/plugin +49 -0
  15. data/vendor/elasticsearch/bin/plugin.bat +22 -0
  16. data/vendor/elasticsearch/bin/service.bat +231 -0
  17. data/vendor/elasticsearch/config/elasticsearch.yml +364 -0
  18. data/vendor/elasticsearch/config/logging.yml +56 -0
  19. data/vendor/elasticsearch/lib/elasticsearch-0.90.7.jar +0 -0
  20. data/vendor/elasticsearch/lib/jna-3.3.0.jar +0 -0
  21. data/vendor/elasticsearch/lib/jts-1.12.jar +0 -0
  22. data/vendor/elasticsearch/lib/log4j-1.2.17.jar +0 -0
  23. data/vendor/elasticsearch/lib/lucene-analyzers-common-4.5.1.jar +0 -0
  24. data/vendor/elasticsearch/lib/lucene-codecs-4.5.1.jar +0 -0
  25. data/vendor/elasticsearch/lib/lucene-core-4.5.1.jar +0 -0
  26. data/vendor/elasticsearch/lib/lucene-grouping-4.5.1.jar +0 -0
  27. data/vendor/elasticsearch/lib/lucene-highlighter-4.5.1.jar +0 -0
  28. data/vendor/elasticsearch/lib/lucene-join-4.5.1.jar +0 -0
  29. data/vendor/elasticsearch/lib/lucene-memory-4.5.1.jar +0 -0
  30. data/vendor/elasticsearch/lib/lucene-misc-4.5.1.jar +0 -0
  31. data/vendor/elasticsearch/lib/lucene-queries-4.5.1.jar +0 -0
  32. data/vendor/elasticsearch/lib/lucene-queryparser-4.5.1.jar +0 -0
  33. data/vendor/elasticsearch/lib/lucene-sandbox-4.5.1.jar +0 -0
  34. data/vendor/elasticsearch/lib/lucene-spatial-4.5.1.jar +0 -0
  35. data/vendor/elasticsearch/lib/lucene-suggest-4.5.1.jar +0 -0
  36. data/vendor/elasticsearch/lib/sigar/libsigar-amd64-freebsd-6.so +0 -0
  37. data/vendor/elasticsearch/lib/sigar/libsigar-amd64-linux.so +0 -0
  38. data/vendor/elasticsearch/lib/sigar/libsigar-amd64-solaris.so +0 -0
  39. data/vendor/elasticsearch/lib/sigar/libsigar-ia64-linux.so +0 -0
  40. data/vendor/elasticsearch/lib/sigar/libsigar-sparc-solaris.so +0 -0
  41. data/vendor/elasticsearch/lib/sigar/libsigar-sparc64-solaris.so +0 -0
  42. data/vendor/elasticsearch/lib/sigar/libsigar-universal-macosx.dylib +0 -0
  43. data/vendor/elasticsearch/lib/sigar/libsigar-universal64-macosx.dylib +0 -0
  44. data/vendor/elasticsearch/lib/sigar/libsigar-x86-freebsd-5.so +0 -0
  45. data/vendor/elasticsearch/lib/sigar/libsigar-x86-freebsd-6.so +0 -0
  46. data/vendor/elasticsearch/lib/sigar/libsigar-x86-linux.so +0 -0
  47. data/vendor/elasticsearch/lib/sigar/libsigar-x86-solaris.so +0 -0
  48. data/vendor/elasticsearch/lib/sigar/sigar-1.6.4.jar +0 -0
  49. data/vendor/elasticsearch/lib/sigar/sigar-amd64-winnt.dll +0 -0
  50. data/vendor/elasticsearch/lib/sigar/sigar-x86-winnt.dll +0 -0
  51. data/vendor/elasticsearch/lib/sigar/sigar-x86-winnt.lib +0 -0
  52. data/vendor/elasticsearch/lib/spatial4j-0.3.jar +0 -0
  53. metadata +109 -0
@@ -0,0 +1,184 @@
1
+ #!/bin/sh
2
+
3
+ # OPTIONS:
4
+ # -f: start in the foreground
5
+ # -p <filename>: log the pid to a file (useful to kill it later)
6
+
7
+ # CONTROLLING STARTUP:
8
+ #
9
+ # This script relies on few environment variables to determine startup
10
+ # behavior, those variables are:
11
+ #
12
+ # ES_CLASSPATH -- A Java classpath containing everything necessary to run.
13
+ # JAVA_OPTS -- Additional arguments to the JVM for heap size, etc
14
+ # ES_JAVA_OPTS -- External Java Opts on top of the defaults set
15
+ #
16
+ #
17
+ # Optionally, exact memory values can be set using the following values, note,
18
+ # they can still be set using the `ES_JAVA_OPTS`. Sample format include "512m", and "10g".
19
+ #
20
+ # ES_HEAP_SIZE -- Sets both the minimum and maximum memory to allocate (recommended)
21
+ #
22
+ # As a convenience, a fragment of shell is sourced in order to set one or
23
+ # more of these variables. This so-called `include' can be placed in a
24
+ # number of locations and will be searched for in order. The lowest
25
+ # priority search path is the same directory as the startup script, and
26
+ # since this is the location of the sample in the project tree, it should
27
+ # almost work Out Of The Box.
28
+ #
29
+ # Any serious use-case though will likely require customization of the
30
+ # include. For production installations, it is recommended that you copy
31
+ # the sample to one of /usr/share/elasticsearch/elasticsearch.in.sh,
32
+ # /usr/local/share/elasticsearch/elasticsearch.in.sh, or
33
+ # /opt/elasticsearch/elasticsearch.in.sh and make your modifications there.
34
+ #
35
+ # Another option is to specify the full path to the include file in the
36
+ # environment. For example:
37
+ #
38
+ # $ ES_INCLUDE=/path/to/in.sh elasticsearch -p /var/run/es.pid
39
+ #
40
+ # Note: This is particularly handy for running multiple instances on a
41
+ # single installation, or for quick tests.
42
+ #
43
+ # If you would rather configure startup entirely from the environment, you
44
+ # can disable the include by exporting an empty ES_INCLUDE, or by
45
+ # ensuring that no include files exist in the aforementioned search list.
46
+ # Be aware that you will be entirely responsible for populating the needed
47
+ # environment variables.
48
+
49
+ CDPATH=""
50
+ SCRIPT="$0"
51
+
52
+ # SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path.
53
+ while [ -h "$SCRIPT" ] ; do
54
+ ls=`ls -ld "$SCRIPT"`
55
+ # Drop everything prior to ->
56
+ link=`expr "$ls" : '.*-> \(.*\)$'`
57
+ if expr "$link" : '/.*' > /dev/null; then
58
+ SCRIPT="$link"
59
+ else
60
+ SCRIPT=`dirname "$SCRIPT"`/"$link"
61
+ fi
62
+ done
63
+
64
+ # determine elasticsearch home
65
+ ES_HOME=`dirname "$SCRIPT"`/..
66
+
67
+ # make ELASTICSEARCH_HOME absolute
68
+ ES_HOME=`cd "$ES_HOME"; pwd`
69
+
70
+
71
+ # If an include wasn't specified in the environment, then search for one...
72
+ if [ "x$ES_INCLUDE" = "x" ]; then
73
+ # Locations (in order) to use when searching for an include file.
74
+ for include in /usr/share/elasticsearch/elasticsearch.in.sh \
75
+ /usr/local/share/elasticsearch/elasticsearch.in.sh \
76
+ /opt/elasticsearch/elasticsearch.in.sh \
77
+ ~/.elasticsearch.in.sh \
78
+ "`dirname "$0"`"/elasticsearch.in.sh; do
79
+ if [ -r "$include" ]; then
80
+ . "$include"
81
+ break
82
+ fi
83
+ done
84
+ # ...otherwise, source the specified include.
85
+ elif [ -r "$ES_INCLUDE" ]; then
86
+ . "$ES_INCLUDE"
87
+ fi
88
+
89
+ if [ -x "$JAVA_HOME/bin/java" ]; then
90
+ JAVA="$JAVA_HOME/bin/java"
91
+ else
92
+ JAVA=$(which java)
93
+ fi
94
+
95
+ if [ ! -x "$JAVA" ]; then
96
+ echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
97
+ exit 1
98
+ fi
99
+
100
+ if [ -z "$ES_CLASSPATH" ]; then
101
+ echo "You must set the ES_CLASSPATH var" >&2
102
+ exit 1
103
+ fi
104
+
105
+ # Special-case path variables.
106
+ case `uname` in
107
+ CYGWIN*)
108
+ ES_CLASSPATH=`cygpath -p -w "$ES_CLASSPATH"`
109
+ ES_HOME=`cygpath -p -w "$ES_HOME"`
110
+ ;;
111
+ esac
112
+
113
+ launch_service()
114
+ {
115
+ pidpath=$1
116
+ foreground=$2
117
+ props=$3
118
+ es_parms="-Delasticsearch"
119
+
120
+ if [ "x$pidpath" != "x" ]; then
121
+ es_parms="$es_parms -Des.pidfile=$pidpath"
122
+ fi
123
+
124
+ # The es-foreground option will tell ElasticSearch not to close stdout/stderr, but it's up to us not to background.
125
+ if [ "x$foreground" != "x" ]; then
126
+ es_parms="$es_parms -Des.foreground=yes"
127
+ exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \
128
+ org.elasticsearch.bootstrap.ElasticSearch
129
+ # exec without running it in the background, makes it replace this shell, we'll never get here...
130
+ # no need to return something
131
+ else
132
+ # Startup ElasticSearch, background it, and write the pid.
133
+ exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \
134
+ org.elasticsearch.bootstrap.ElasticSearch <&- &
135
+ return $?
136
+ fi
137
+ }
138
+
139
+ # Parse any command line options.
140
+ args=`getopt vfhp:D:X: "$@"`
141
+ eval set -- "$args"
142
+
143
+ while true; do
144
+ case $1 in
145
+ -v)
146
+ "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \
147
+ org.elasticsearch.Version
148
+ exit 0
149
+ ;;
150
+ -p)
151
+ pidfile="$2"
152
+ shift 2
153
+ ;;
154
+ -f)
155
+ foreground="yes"
156
+ shift
157
+ ;;
158
+ -h)
159
+ echo "Usage: $0 [-f] [-h] [-p pidfile]"
160
+ exit 0
161
+ ;;
162
+ -D)
163
+ properties="$properties -D$2"
164
+ shift 2
165
+ ;;
166
+ -X)
167
+ properties="$properties -X$2"
168
+ shift 2
169
+ ;;
170
+ --)
171
+ shift
172
+ break
173
+ ;;
174
+ *)
175
+ echo "Error parsing argument $1!" >&2
176
+ exit 1
177
+ ;;
178
+ esac
179
+ done
180
+
181
+ # Start up the service
182
+ launch_service "$pidfile" "$foreground" "$properties"
183
+
184
+ exit $?
@@ -0,0 +1,79 @@
1
+ @echo off
2
+
3
+ SETLOCAL
4
+
5
+ if NOT DEFINED JAVA_HOME goto err
6
+
7
+ set SCRIPT_DIR=%~dp0
8
+ for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI
9
+
10
+
11
+ REM ***** JAVA options *****
12
+
13
+ if "%ES_MIN_MEM%" == "" (
14
+ set ES_MIN_MEM=256m
15
+ )
16
+
17
+ if "%ES_MAX_MEM%" == "" (
18
+ set ES_MAX_MEM=1g
19
+ )
20
+
21
+ if NOT "%ES_HEAP_SIZE%" == "" (
22
+ set ES_MIN_MEM=%ES_HEAP_SIZE%
23
+ set ES_MAX_MEM=%ES_HEAP_SIZE%
24
+ )
25
+
26
+ set JAVA_OPTS=%JAVA_OPTS% -Xms%ES_MIN_MEM% -Xmx%ES_MAX_MEM%
27
+
28
+ if NOT "%ES_HEAP_NEWSIZE%" == "" (
29
+ set JAVA_OPTS=%JAVA_OPTS% -Xmn%ES_HEAP_NEWSIZE%
30
+ )
31
+
32
+ if NOT "%ES_DIRECT_SIZE%" == "" (
33
+ set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=%ES_DIRECT_SIZE%
34
+ )
35
+
36
+ set JAVA_OPTS=%JAVA_OPTS% -Xss256k
37
+
38
+ REM Enable aggressive optimizations in the JVM
39
+ REM - Disabled by default as it might cause the JVM to crash
40
+ REM set JAVA_OPTS=%JAVA_OPTS% -XX:+AggressiveOpts
41
+
42
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParNewGC
43
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+UseConcMarkSweepGC
44
+
45
+ set JAVA_OPTS=%JAVA_OPTS% -XX:CMSInitiatingOccupancyFraction=75
46
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+UseCMSInitiatingOccupancyOnly
47
+
48
+ REM When running under Java 7
49
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+UseCondCardMark
50
+
51
+ REM GC logging options -- uncomment to enable
52
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails
53
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps
54
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram
55
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution
56
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime
57
+ REM JAVA_OPTS=%JAVA_OPTS% -Xloggc:/var/log/elasticsearch/gc.log
58
+
59
+ REM Causes the JVM to dump its heap on OutOfMemory.
60
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError
61
+ REM The path to the heap dump location, note directory must exists and have enough
62
+ REM space for a full heap dump.
63
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof
64
+
65
+ set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/elasticsearch-0.90.7.jar;%ES_HOME%/lib/*;%ES_HOME%/lib/sigar/*
66
+ set ES_PARAMS=-Delasticsearch -Des-foreground=yes -Des.path.home="%ES_HOME%"
67
+
68
+ "%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% %ES_PARAMS% %* -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.ElasticSearch"
69
+ goto finally
70
+
71
+
72
+ :err
73
+ echo JAVA_HOME environment variable must be set!
74
+ pause
75
+
76
+
77
+ :finally
78
+
79
+ ENDLOCAL
@@ -0,0 +1,64 @@
1
+ #!/bin/sh
2
+
3
+ ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/elasticsearch-0.90.7.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*
4
+
5
+ if [ "x$ES_MIN_MEM" = "x" ]; then
6
+ ES_MIN_MEM=256m
7
+ fi
8
+ if [ "x$ES_MAX_MEM" = "x" ]; then
9
+ ES_MAX_MEM=1g
10
+ fi
11
+ if [ "x$ES_HEAP_SIZE" != "x" ]; then
12
+ ES_MIN_MEM=$ES_HEAP_SIZE
13
+ ES_MAX_MEM=$ES_HEAP_SIZE
14
+ fi
15
+
16
+ # min and max heap sizes should be set to the same value to avoid
17
+ # stop-the-world GC pauses during resize, and so that we can lock the
18
+ # heap in memory on startup to prevent any of it from being swapped
19
+ # out.
20
+ JAVA_OPTS="$JAVA_OPTS -Xms${ES_MIN_MEM}"
21
+ JAVA_OPTS="$JAVA_OPTS -Xmx${ES_MAX_MEM}"
22
+
23
+ # new generation
24
+ if [ "x$ES_HEAP_NEWSIZE" != "x" ]; then
25
+ JAVA_OPTS="$JAVA_OPTS -Xmn${ES_HEAP_NEWSIZE}"
26
+ fi
27
+
28
+ # max direct memory
29
+ if [ "x$ES_DIRECT_SIZE" != "x" ]; then
30
+ JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=${ES_DIRECT_SIZE}"
31
+ fi
32
+
33
+ # reduce the per-thread stack size
34
+ JAVA_OPTS="$JAVA_OPTS -Xss256k"
35
+
36
+ # set to headless, just in case
37
+ JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
38
+
39
+ # Force the JVM to use IPv4 stack
40
+ if [ "x$ES_USE_IPV4" != "x" ]; then
41
+ JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
42
+ fi
43
+
44
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
45
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
46
+
47
+ JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
48
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
49
+
50
+ # GC logging options
51
+ if [ "x$ES_USE_GC_LOGGING" != "x" ]; then
52
+ JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
53
+ JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps"
54
+ JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram"
55
+ JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution"
56
+ JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"
57
+ JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/elasticsearch/gc.log"
58
+ fi
59
+
60
+ # Causes the JVM to dump its heap on OutOfMemory.
61
+ JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
62
+ # The path to the heap dump location, note directory must exists and have enough
63
+ # space for a full heap dump.
64
+ #JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof"
@@ -0,0 +1,49 @@
1
+ #!/bin/sh
2
+
3
+ CDPATH=""
4
+ SCRIPT="$0"
5
+
6
+ # SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path.
7
+ while [ -h "$SCRIPT" ] ; do
8
+ ls=`ls -ld "$SCRIPT"`
9
+ # Drop everything prior to ->
10
+ link=`expr "$ls" : '.*-> \(.*\)$'`
11
+ if expr "$link" : '/.*' > /dev/null; then
12
+ SCRIPT="$link"
13
+ else
14
+ SCRIPT=`dirname "$SCRIPT"`/"$link"
15
+ fi
16
+ done
17
+
18
+ # determine elasticsearch home
19
+ ES_HOME=`dirname "$SCRIPT"`/..
20
+
21
+ # make ELASTICSEARCH_HOME absolute
22
+ ES_HOME=`cd "$ES_HOME"; pwd`
23
+
24
+
25
+ if [ -x "$JAVA_HOME/bin/java" ]; then
26
+ JAVA=$JAVA_HOME/bin/java
27
+ else
28
+ JAVA=`which java`
29
+ fi
30
+
31
+ # real getopt cannot be used because we need to hand options over to the PluginManager
32
+ while [ $# -gt 0 ]; do
33
+ case $1 in
34
+ -D*=*)
35
+ properties="$properties $1"
36
+ ;;
37
+ -D*)
38
+ var=$1
39
+ shift
40
+ properties="$properties $var=$1"
41
+ ;;
42
+ *)
43
+ args="$args $1"
44
+ esac
45
+ shift
46
+ done
47
+
48
+ exec $JAVA $JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args
49
+
@@ -0,0 +1,22 @@
1
+ @echo off
2
+
3
+ SETLOCAL
4
+
5
+ if NOT DEFINED JAVA_HOME goto err
6
+
7
+ set SCRIPT_DIR=%~dp0
8
+ for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI
9
+
10
+
11
+ "%JAVA_HOME%\bin\java" %JAVA_OPTS% -Xmx64m -Xms16m -Des.path.home="%ES_HOME%" -cp "%ES_HOME%/lib/*;" "org.elasticsearch.plugins.PluginManager" %*
12
+ goto finally
13
+
14
+
15
+ :err
16
+ echo JAVA_HOME environment variable must be set!
17
+ pause
18
+
19
+
20
+ :finally
21
+
22
+ ENDLOCAL
@@ -0,0 +1,231 @@
1
+ @echo off
2
+ SETLOCAL
3
+
4
+ if NOT DEFINED JAVA_HOME goto err
5
+
6
+ set SCRIPT_DIR=%~dp0
7
+ for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI
8
+
9
+ rem Detect JVM version to figure out appropriate executable to use
10
+ if not exist "%JAVA_HOME%\bin\java.exe" (
11
+ echo JAVA_HOME points to an invalid Java installation (no java.exe found in "%JAVA_HOME%"^). Existing...
12
+ goto:eof
13
+ )
14
+ "%JAVA_HOME%\bin\java" -version 2>&1 | find "64-Bit" >nul:
15
+
16
+ if errorlevel 1 goto x86
17
+ set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe
18
+ set SERVICE_ID=elasticsearch-service-x64
19
+ set ARCH=64-bit
20
+ goto checkExe
21
+
22
+ :x86
23
+ set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x86.exe
24
+ set SERVICE_ID=elasticsearch-service-x86
25
+ set ARCH=32-bit
26
+
27
+ :checkExe
28
+ if EXIST "%EXECUTABLE%" goto okExe
29
+ echo elasticsearch-service-(x86|x64).exe was not found...
30
+
31
+ :okExe
32
+ set ES_VERSION=0.90.7
33
+
34
+ if "%LOG_DIR%" == "" set LOG_DIR=%ES_HOME%\logs
35
+
36
+ if "x%1x" == "xx" goto displayUsage
37
+ set SERVICE_CMD=%1
38
+ shift
39
+ if "x%1x" == "xx" goto checkServiceCmd
40
+ set SERVICE_ID=%1
41
+
42
+ :checkServiceCmd
43
+
44
+ if "%LOG_OPTS%" == "" set LOG_OPTS=--LogPath "%LOG_DIR%" --LogPrefix "%SERVICE_ID%" --StdError auto --StdOutput auto
45
+
46
+ if /i %SERVICE_CMD% == install goto doInstall
47
+ if /i %SERVICE_CMD% == remove goto doRemove
48
+ if /i %SERVICE_CMD% == start goto doStart
49
+ if /i %SERVICE_CMD% == stop goto doStop
50
+ if /i %SERVICE_CMD% == manager goto doManagment
51
+ echo Unknown option "%SERVICE_CMD%"
52
+
53
+ :displayUsage
54
+ echo.
55
+ echo Usage: service.bat install^|remove^|start^|stop^|manager [SERVICE_ID]
56
+ goto:eof
57
+
58
+ :doStart
59
+ "%EXECUTABLE%" //ES//%SERVICE_ID% %LOG_OPTS%
60
+ if not errorlevel 1 goto started
61
+ echo Failed starting '%SERVICE_ID%' service
62
+ goto:eof
63
+ :started
64
+ echo The service '%SERVICE_ID%' has been started
65
+ goto:eof
66
+
67
+ :doStop
68
+ "%EXECUTABLE%" //SS//%SERVICE_ID% %LOG_OPTS%
69
+ if not errorlevel 1 goto stopped
70
+ echo Failed stopping '%SERVICE_ID%' service
71
+ goto:eof
72
+ :stopped
73
+ echo The service '%SERVICE_ID%' has been stopped
74
+ goto:eof
75
+
76
+ :doManagment
77
+ set EXECUTABLE_MGR=%ES_HOME%\bin\elasticsearch-service-mgr.exe
78
+ "%EXECUTABLE_MGR%" //ES//%SERVICE_ID%
79
+ if not errorlevel 1 goto managed
80
+ echo Failed starting service manager for '%SERVICE_ID%'
81
+ goto:eof
82
+ :managed
83
+ echo Succesfully started service manager for '%SERVICE_ID%'.
84
+ goto:eof
85
+
86
+ :doRemove
87
+ rem Remove the service
88
+ "%EXECUTABLE%" //DS//%SERVICE_ID% %LOG_OPTS%
89
+ if not errorlevel 1 goto removed
90
+ echo Failed removing '%SERVICE_ID%' service
91
+ goto:eof
92
+ :removed
93
+ echo The service '%SERVICE_ID%' has been removed
94
+ goto:eof
95
+
96
+ :doInstall
97
+ echo Installing service : "%SERVICE_ID%"
98
+ echo Using JAVA_HOME (%ARCH%): "%JAVA_HOME%"
99
+
100
+ rem Check JVM server dll first
101
+ set JVM_DLL=%JAVA_HOME%\jre\bin\server\jvm.dll
102
+ if exist "%JVM_DLL%" goto foundJVM
103
+
104
+ rem Check 'server' JRE (JRE installed on Windows Server)
105
+ set JVM_DLL=%JAVA_HOME%\bin\server\jvm.dll
106
+ if exist "%JVM_DLL%" goto foundJVM
107
+
108
+ rem Fallback to 'client' JRE
109
+ set JVM_DLL=%JAVA_HOME%\bin\client\jvm.dll
110
+
111
+ if exist "%JVM_DLL%" (
112
+ echo Warning: JAVA_HOME points to a JRE and not JDK installation; a client (not a server^) JVM will be used...
113
+ ) else (
114
+ echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Existing...
115
+ goto:eof
116
+ )
117
+
118
+ :foundJVM
119
+ if "%ES_MIN_MEM%" == "" set ES_MIN_MEM=256m
120
+ if "%ES_MAX_MEM%" == "" set ES_MAX_MEM=1g
121
+
122
+ if NOT "%ES_HEAP_SIZE%" == "" set ES_MIN_MEM=%ES_HEAP_SIZE%
123
+ if NOT "%ES_HEAP_SIZE%" == "" set ES_MAX_MEM=%ES_HEAP_SIZE%
124
+
125
+ call:convertxm %ES_MIN_MEM% JVM_XMS
126
+ call:convertxm %ES_MAX_MEM% JVM_XMX
127
+
128
+ rem java_opts might be empty - init to avoid tripping commons daemon (if the command starts with ;)
129
+ if not "%JAVA_OPTS%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParNewGC
130
+ if "%JAVA_OPTS%" == "" set JAVA_OPTS=-XX:+UseParNewGC
131
+
132
+ if NOT "%ES_HEAP_NEWSIZE%" == "" set JAVA_OPTS=%JAVA_OPTS% -Xmn%ES_HEAP_NEWSIZE%
133
+
134
+ if NOT "%ES_DIRECT_SIZE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=%ES_DIRECT_SIZE%
135
+
136
+ rem thread stack size
137
+ set JVM_SS=256
138
+
139
+ REM Enable aggressive optimizations in the JVM
140
+ REM - Disabled by default as it might cause the JVM to crash
141
+ REM set JAVA_OPTS=%JAVA_OPTS% -XX:+AggressiveOpts
142
+
143
+
144
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+UseConcMarkSweepGC
145
+
146
+ set JAVA_OPTS=%JAVA_OPTS% -XX:CMSInitiatingOccupancyFraction=75
147
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+UseCMSInitiatingOccupancyOnly
148
+
149
+ REM GC logging options -- uncomment to enable
150
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails
151
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps
152
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram
153
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution
154
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime
155
+ REM JAVA_OPTS=%JAVA_OPTS% -Xloggc:/var/log/elasticsearch/gc.log
156
+
157
+ REM Causes the JVM to dump its heap on OutOfMemory.
158
+ set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError
159
+ REM The path to the heap dump location, note directory must exists and have enough
160
+ REM space for a full heap dump.
161
+ REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof
162
+
163
+ if "%DATA_DIR%" == "" set DATA_DIR=%ES_HOME%\data
164
+
165
+ if "%WORK_DIR%" == "" set WORK_DIR=%ES_HOME%
166
+
167
+ if "%CONF_DIR%" == "" set CONF_DIR=%ES_HOME%\config
168
+
169
+ if "%CONF_FILE%" == "" set CONF_FILE=%ES_HOME%\config\elasticsearch.yml
170
+
171
+ set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/elasticsearch-%ES_VERSION%.jar;%ES_HOME%/lib/*;%ES_HOME%/lib/sigar/*
172
+ 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%"
173
+
174
+ set JVM_OPTS=%JAVA_OPTS: =;%
175
+
176
+ if not "%ES_JAVA_OPTS%" == "" set JVM_ES_JAVA_OPTS=%ES_JAVA_OPTS: =#%
177
+ if not "%ES_JAVA_OPTS%" == "" set JVM_OPTS=%JVM_OPTS%;%JVM_ES_JAVA_OPTS%
178
+
179
+ if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
180
+ if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0
181
+
182
+ "%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%"
183
+
184
+
185
+ if not errorlevel 1 goto installed
186
+ echo Failed installing '%SERVICE_ID%' service
187
+ goto:eof
188
+
189
+ :installed
190
+ echo The service '%SERVICE_ID%' has been installed.
191
+ goto:eof
192
+
193
+ :err
194
+ echo JAVA_HOME environment variable must be set!
195
+ pause
196
+
197
+ goto:eof
198
+
199
+ rem ---
200
+ rem Function for converting Xm[s|x] values into MB which Commons Daemon accepts
201
+ rem ---
202
+ :convertxm
203
+ set value=%~1
204
+ rem extract last char (unit)
205
+ set unit=%value:~-1%
206
+ rem assume the unit is specified
207
+ set conv=%value:~0,-1%
208
+
209
+ if "%unit%" == "k" goto kilo
210
+ if "%unit%" == "K" goto kilo
211
+ if "%unit%" == "m" goto mega
212
+ if "%unit%" == "M" goto mega
213
+ if "%unit%" == "g" goto giga
214
+ if "%unit%" == "G" goto giga
215
+
216
+ rem no unit found, must be bytes; consider the whole value
217
+ set conv=%value%
218
+ rem convert to KB
219
+ set /a conv=%conv% / 1024
220
+ :kilo
221
+ rem convert to MB
222
+ set /a conv=%conv% / 1024
223
+ goto mega
224
+ :giga
225
+ rem convert to MB
226
+ set /a conv=%conv% * 1024
227
+ :mega
228
+ set "%~2=%conv%"
229
+ goto:eof
230
+
231
+ ENDLOCAL