Service Wrapper: A Java Service Wrapper integration, closes #154.
This commit is contained in:
parent
69df71d2e3
commit
97958c3a66
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,118 @@
|
||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
rem Java Service Wrapper command based script.
|
||||||
|
|
||||||
|
rem -----------------------------------------------------------------------------
|
||||||
|
rem These settings can be modified to fit the needs of your application
|
||||||
|
rem Optimized for use with version 3.4.0 of the Wrapper.
|
||||||
|
|
||||||
|
rem SET ES_HOME
|
||||||
|
set ES_HOME=%~dp0\..\..
|
||||||
|
|
||||||
|
rem The base name for the Wrapper binary.
|
||||||
|
set _WRAPPER_BASE=\exec\elasticsearch
|
||||||
|
|
||||||
|
rem The name and location of the Wrapper configuration file.
|
||||||
|
rem (Do not remove quotes.)
|
||||||
|
set _WRAPPER_CONF="..\elasticsearch.conf"
|
||||||
|
|
||||||
|
rem Do not modify anything beyond this point
|
||||||
|
rem -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if "%OS%"=="Windows_NT" goto nt
|
||||||
|
echo This script only works with NT-based versions of Windows.
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:nt
|
||||||
|
rem Find the application home.
|
||||||
|
rem %~dp0 is location of current script under NT
|
||||||
|
set _REALPATH=%~dp0
|
||||||
|
|
||||||
|
rem
|
||||||
|
rem Decide on the specific Wrapper binary to use (See delta-pack)
|
||||||
|
rem
|
||||||
|
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64
|
||||||
|
if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64
|
||||||
|
set _WRAPPER_L_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe
|
||||||
|
goto search
|
||||||
|
:amd64
|
||||||
|
set _WRAPPER_L_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe
|
||||||
|
goto search
|
||||||
|
:ia64
|
||||||
|
set _WRAPPER_L_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-ia-64.exe
|
||||||
|
goto search
|
||||||
|
:search
|
||||||
|
set _WRAPPER_EXE=%_WRAPPER_L_EXE%
|
||||||
|
if exist "%_WRAPPER_EXE%" goto validate
|
||||||
|
set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe
|
||||||
|
if exist "%_WRAPPER_EXE%" goto validate
|
||||||
|
echo Unable to locate a Wrapper executable using any of the following names:
|
||||||
|
echo %_WRAPPER_L_EXE%
|
||||||
|
echo %_WRAPPER_EXE%
|
||||||
|
pause
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:validate
|
||||||
|
rem
|
||||||
|
rem Find the requested command.
|
||||||
|
rem
|
||||||
|
for /F %%v in ('echo %1^|findstr "^console$ ^start$ ^pause$ ^resume$ ^stop$ ^restart$ ^install$ ^remove$"') do call :exec set COMMAND=%%v
|
||||||
|
|
||||||
|
if "%COMMAND%" == "" (
|
||||||
|
echo Usage: %0 { console : start : pause : resume : stop : restart : install : remove }
|
||||||
|
pause
|
||||||
|
goto :eof
|
||||||
|
) else (
|
||||||
|
shift
|
||||||
|
)
|
||||||
|
|
||||||
|
rem
|
||||||
|
rem Run the application.
|
||||||
|
rem At runtime, the current directory will be that of wrapper.exe
|
||||||
|
rem
|
||||||
|
call :%COMMAND%
|
||||||
|
if errorlevel 1 goto callerror
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:callerror
|
||||||
|
echo An error occurred in the process.
|
||||||
|
pause
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:console
|
||||||
|
"%_WRAPPER_EXE%" -c %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:start
|
||||||
|
"%_WRAPPER_EXE%" -t %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:pause
|
||||||
|
"%_WRAPPER_EXE%" -a %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:resume
|
||||||
|
"%_WRAPPER_EXE%" -e %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:stop
|
||||||
|
"%_WRAPPER_EXE%" -p %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:install
|
||||||
|
"%_WRAPPER_EXE%" -i %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:remove
|
||||||
|
"%_WRAPPER_EXE%" -r %_WRAPPER_CONF%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:restart
|
||||||
|
call :stop
|
||||||
|
call :start
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:exec
|
||||||
|
%*
|
||||||
|
goto :eof
|
|
@ -0,0 +1,125 @@
|
||||||
|
set.default.ES_HOME=<Path to ElasticSearch Home>
|
||||||
|
|
||||||
|
#********************************************************************
|
||||||
|
# Wrapper Timeout Properties
|
||||||
|
#********************************************************************
|
||||||
|
# How long to wait for the JVM to start (in seconds)
|
||||||
|
wrapper.startup.timeout=300
|
||||||
|
# How long to wait for the JVM to stop (in seconds)
|
||||||
|
wrapper.shutdown.timeout=300
|
||||||
|
# When a ping will timeout to consider the JVM hung (in seconds)
|
||||||
|
wrapper.ping.timeout=300
|
||||||
|
|
||||||
|
#********************************************************************
|
||||||
|
# Wrapper Java Properties
|
||||||
|
#********************************************************************
|
||||||
|
# Java Application
|
||||||
|
wrapper.java.command=java
|
||||||
|
|
||||||
|
# Tell the Wrapper to log the full generated Java command line.
|
||||||
|
#wrapper.java.command.loglevel=INFO
|
||||||
|
|
||||||
|
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
|
||||||
|
|
||||||
|
wrapper.working.dir=%ES_HOME%
|
||||||
|
|
||||||
|
# Java Classpath (include wrapper.jar) Add class path elements as
|
||||||
|
# needed starting from 1
|
||||||
|
wrapper.java.classpath.1=%ES_HOME%/bin/service/lib/wrapper.jar
|
||||||
|
wrapper.java.classpath.2=%ES_HOME%/lib/*.jar
|
||||||
|
|
||||||
|
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
|
||||||
|
wrapper.java.library.path.1=%ES_HOME%/bin/service/lib
|
||||||
|
|
||||||
|
# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
|
||||||
|
wrapper.java.additional.auto_bits=TRUE
|
||||||
|
|
||||||
|
# Java Additional Parameters
|
||||||
|
wrapper.java.additional.1=-Delasticsearch-service
|
||||||
|
wrapper.java.additional.2=-Des-foreground=yes
|
||||||
|
wrapper.java.additional.3=-Des.path.home=%ES_HOME%
|
||||||
|
wrapper.java.additional.4=-Djline.enabled=true
|
||||||
|
wrapper.java.additional.5=-XX:+AggressiveOpts
|
||||||
|
wrapper.java.additional.6=-XX:+UseParNewGC
|
||||||
|
wrapper.java.additional.7=-XX:+UseConcMarkSweepGC
|
||||||
|
wrapper.java.additional.8=-XX:+CMSParallelRemarkEnabled
|
||||||
|
wrapper.java.additional.9=-XX:+HeapDumpOnOutOfMemoryError
|
||||||
|
|
||||||
|
# Initial Java Heap Size (in MB)
|
||||||
|
wrapper.java.initmemory=128
|
||||||
|
|
||||||
|
# Maximum Java Heap Size (in MB)
|
||||||
|
wrapper.java.maxmemory=1024
|
||||||
|
|
||||||
|
# Application parameters. Add parameters as needed starting from 1
|
||||||
|
wrapper.app.parameter.1=org.elasticsearch.bootstrap.Bootstrap
|
||||||
|
|
||||||
|
#********************************************************************
|
||||||
|
# Wrapper Logging Properties
|
||||||
|
#********************************************************************
|
||||||
|
# Enables Debug output from the Wrapper.
|
||||||
|
# wrapper.debug=TRUE
|
||||||
|
|
||||||
|
# Format of output for the console. (See docs for formats)
|
||||||
|
wrapper.console.format=PM
|
||||||
|
|
||||||
|
# Log Level for console output. (See docs for log levels)
|
||||||
|
wrapper.console.loglevel=INFO
|
||||||
|
|
||||||
|
# Log file to use for wrapper output logging.
|
||||||
|
wrapper.logfile=%ES_HOME%/work/logs/service.log
|
||||||
|
|
||||||
|
# Format of output for the log file. (See docs for formats)
|
||||||
|
wrapper.logfile.format=LPTM
|
||||||
|
|
||||||
|
# Log Level for log file output. (See docs for log levels)
|
||||||
|
wrapper.logfile.loglevel=INFO
|
||||||
|
|
||||||
|
# Maximum size that the log file will be allowed to grow to before
|
||||||
|
# the log is rolled. Size is specified in bytes. The default value
|
||||||
|
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
|
||||||
|
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
|
||||||
|
wrapper.logfile.maxsize=0
|
||||||
|
|
||||||
|
# Maximum number of rolled log files which will be allowed before old
|
||||||
|
# files are deleted. The default value of 0 implies no limit.
|
||||||
|
wrapper.logfile.maxfiles=0
|
||||||
|
|
||||||
|
# Log Level for sys/event log output. (See docs for log levels)
|
||||||
|
wrapper.syslog.loglevel=NONE
|
||||||
|
|
||||||
|
#********************************************************************
|
||||||
|
# Wrapper General Properties
|
||||||
|
#********************************************************************
|
||||||
|
# Allow for the use of non-contiguous numbered properties
|
||||||
|
wrapper.ignore_sequence_gaps=TRUE
|
||||||
|
|
||||||
|
# Title to use when running as a console
|
||||||
|
wrapper.console.title=ElasticSearch
|
||||||
|
|
||||||
|
#********************************************************************
|
||||||
|
# Wrapper Windows NT/2000/XP Service Properties
|
||||||
|
#********************************************************************
|
||||||
|
# WARNING - Do not modify any of these properties when an application
|
||||||
|
# using this configuration file has been installed as a service.
|
||||||
|
# Please uninstall the service before modifying this section. The
|
||||||
|
# service can then be reinstalled.
|
||||||
|
|
||||||
|
# Name of the service
|
||||||
|
wrapper.name=ElasticSearch
|
||||||
|
|
||||||
|
# Display name of the service
|
||||||
|
wrapper.displayname=ElasticSearch
|
||||||
|
|
||||||
|
# Description of the service
|
||||||
|
wrapper.description=Open Source, Distributed, RESTful Search Engine
|
||||||
|
|
||||||
|
# Service dependencies. Add dependencies as needed starting from 1
|
||||||
|
wrapper.ntservice.dependency.1=
|
||||||
|
|
||||||
|
# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START
|
||||||
|
wrapper.ntservice.starttype=AUTO_START
|
||||||
|
|
||||||
|
# Allow the service to interact with the desktop.
|
||||||
|
wrapper.ntservice.interactive=false
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
export DIST_BITS="32"
|
||||||
|
`dirname $0`/elasticsearch $1
|
|
@ -0,0 +1,4 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
export DIST_BITS="64"
|
||||||
|
`dirname $0`/elasticsearch $1
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -87,10 +87,18 @@ task zip(type: Zip, dependsOn: ['explodedDist']) {
|
||||||
from(explodedDistDir) {
|
from(explodedDistDir) {
|
||||||
into zipRootFolder
|
into zipRootFolder
|
||||||
exclude 'bin/elasticsearch'
|
exclude 'bin/elasticsearch'
|
||||||
|
exclude 'bin/service/elasticsearch'
|
||||||
|
exclude 'bin/service/elasticsearch32'
|
||||||
|
exclude 'bin/service/elasticsearch64'
|
||||||
|
exclude 'bin/service/exec/**'
|
||||||
}
|
}
|
||||||
from(explodedDistDir) {
|
from(explodedDistDir) {
|
||||||
into zipRootFolder
|
into zipRootFolder
|
||||||
include 'bin/elasticsearch'
|
include 'bin/elasticsearch'
|
||||||
|
include 'bin/service/elasticsearch'
|
||||||
|
include 'bin/service/elasticsearch32'
|
||||||
|
include 'bin/service/elasticsearch64'
|
||||||
|
include 'bin/service/exec/**'
|
||||||
fileMode = 0755
|
fileMode = 0755
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,21 @@ public class TransportNodesShutdown extends TransportNodesOperationAction<NodesS
|
||||||
logger.info("Shutting down in [{}]", request.delay);
|
logger.info("Shutting down in [{}]", request.delay);
|
||||||
threadPool.schedule(new Runnable() {
|
threadPool.schedule(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
node.close();
|
boolean shutdownWithWrapper = false;
|
||||||
|
if (System.getProperty("elasticsearch-service") != null) {
|
||||||
|
try {
|
||||||
|
Class wrapperManager = settings.getClassLoader().loadClass("org.tanukisoftware.wrapper.WrapperManager");
|
||||||
|
logger.info("Initiating requested shutdown (using service)");
|
||||||
|
wrapperManager.getMethod("stopAndReturn", int.class).invoke(null, 0);
|
||||||
|
shutdownWithWrapper = true;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!shutdownWithWrapper) {
|
||||||
|
logger.info("Initiating requested shutdown");
|
||||||
|
node.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, request.delay.millis(), TimeUnit.MILLISECONDS);
|
}, request.delay.millis(), TimeUnit.MILLISECONDS);
|
||||||
return new NodesShutdownResponse.NodeShutdownResponse(clusterService.state().nodes().localNode());
|
return new NodesShutdownResponse.NodeShutdownResponse(clusterService.state().nodes().localNode());
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.bootstrap;
|
package org.elasticsearch.bootstrap;
|
||||||
|
|
||||||
import org.elasticsearch.util.guice.inject.CreationException;
|
|
||||||
import org.elasticsearch.util.guice.inject.spi.Message;
|
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
|
@ -30,6 +28,8 @@ import org.elasticsearch.node.NodeBuilder;
|
||||||
import org.elasticsearch.node.internal.InternalSettingsPerparer;
|
import org.elasticsearch.node.internal.InternalSettingsPerparer;
|
||||||
import org.elasticsearch.util.Classes;
|
import org.elasticsearch.util.Classes;
|
||||||
import org.elasticsearch.util.Tuple;
|
import org.elasticsearch.util.Tuple;
|
||||||
|
import org.elasticsearch.util.guice.inject.CreationException;
|
||||||
|
import org.elasticsearch.util.guice.inject.spi.Message;
|
||||||
import org.elasticsearch.util.jline.ANSI;
|
import org.elasticsearch.util.jline.ANSI;
|
||||||
import org.elasticsearch.util.logging.ESLogger;
|
import org.elasticsearch.util.logging.ESLogger;
|
||||||
import org.elasticsearch.util.logging.Loggers;
|
import org.elasticsearch.util.logging.Loggers;
|
||||||
|
@ -39,8 +39,8 @@ import org.elasticsearch.util.settings.Settings;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.elasticsearch.util.gcommon.collect.Sets.*;
|
|
||||||
import static jline.ANSIBuffer.ANSICodes.*;
|
import static jline.ANSIBuffer.ANSICodes.*;
|
||||||
|
import static org.elasticsearch.util.gcommon.collect.Sets.*;
|
||||||
import static org.elasticsearch.util.settings.ImmutableSettings.Builder.*;
|
import static org.elasticsearch.util.settings.ImmutableSettings.Builder.*;
|
||||||
import static org.elasticsearch.util.settings.ImmutableSettings.*;
|
import static org.elasticsearch.util.settings.ImmutableSettings.*;
|
||||||
|
|
||||||
|
@ -131,6 +131,10 @@ public class Bootstrap {
|
||||||
String pidFile = System.getProperty("es-pidfile");
|
String pidFile = System.getProperty("es-pidfile");
|
||||||
|
|
||||||
boolean foreground = System.getProperty("es-foreground") != null;
|
boolean foreground = System.getProperty("es-foreground") != null;
|
||||||
|
// handle the wrapper system property, if its a service, don't run as a service
|
||||||
|
if (System.getProperty("wrapper.service", "XXX").equalsIgnoreCase("true")) {
|
||||||
|
foreground = false;
|
||||||
|
}
|
||||||
|
|
||||||
Tuple<Settings, Environment> tuple = null;
|
Tuple<Settings, Environment> tuple = null;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue