Skip to content
Snippets Groups Projects
Commit 5799c9a2 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

ES: enable log into file. Add option for node network host

ES: fix --daemon to NOT stop until kill sig
parent 17a7d410
Branches
Tags
No related merge requests found
Showing with 52 additions and 21 deletions
...@@ -115,8 +115,9 @@ ...@@ -115,8 +115,9 @@
<ucoinj.plugins.directory>${basedir}}/src/test/es-home/plugins</ucoinj.plugins.directory> <ucoinj.plugins.directory>${basedir}}/src/test/es-home/plugins</ucoinj.plugins.directory>
<es.http.cors.allow-origin>*</es.http.cors.allow-origin> <es.http.cors.allow-origin>*</es.http.cors.allow-origin>
<exec.args> <exec.args>
start reset-market reset-registry index --host metab.ucoin.fr --port 9201 start index --host metab.ucoin.fr --port 9201
</exec.args> </exec.args>
<ucoinj.log.file>${project.build.directory}/exec.log</ucoinj.log.file>
</properties> </properties>
</profile> </profile>
......
...@@ -32,7 +32,7 @@ echo . ...@@ -32,7 +32,7 @@ echo .
set OLDDIR=%CD% set OLDDIR=%CD%
cd /d %~dp0% cd /d %~dp0%
call "%JAVA_COMMAND%" %JAVA_OPTS% "-Ducoinj.log.file=%APP_LOG_FILE%" "-Ducoinj-elasticsearch.config=%APP_CONF_FILE%" "-Ducoinj.plugins.directory=%APP_BASEDIR%\plugins" -Djna.nosys=true -jar ucoinj-elasticsearch-plugin-${project.version}.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 call "%JAVA_COMMAND%" %JAVA_OPTS% "-Ducoinj.basedir=%APP_BASEDIR%" "-Ducoinj.plugins.directory=%APP_BASEDIR%\plugins" "-Ducoinj.log.file=%APP_LOG_FILE%" "-Ducoinj-elasticsearch.config=%APP_CONF_FILE%" -Ducoinj.launch.mode=full -Djna.nosys=true -Des.http.cors.allow-origin=* -jar ucoinj-elasticsearch-plugin-${project.version}.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
set exitcode=%ERRORLEVEL% set exitcode=%ERRORLEVEL%
echo Stop with exitcode: %exitcode% echo Stop with exitcode: %exitcode%
cd %OLDDIR% cd %OLDDIR%
......
...@@ -25,7 +25,7 @@ if [ -d $JAVA_HOME ]; then ...@@ -25,7 +25,7 @@ if [ -d $JAVA_HOME ]; then
echo "launch java" echo "launch java"
echo "java command: $JAVA_COMMAND" echo "java command: $JAVA_COMMAND"
$JAVA_COMMAND $MEMORY $APP_JVM_OPTS -Ducoinj.log.file=$APP_LOG_FILE -Ducoinj-elasticsearch.config=$APP_CONF_FILE -Djna.nosys=true -Ducoinj.basedir=$APP_BASEDIR -Ducoinj.plugins.directory=$APP_BASEDIR/plugins -Des.http.cors.allow-origin=* -jar ucoinj-elasticsearch-plugin-${project.version}.jar $* $JAVA_COMMAND $MEMORY $APP_JVM_OPTS -Ducoinj.basedir=$APP_BASEDIR -Ducoinj.plugins.directory=$APP_BASEDIR/plugins -Ducoinj.log.file=$APP_LOG_FILE -Ducoinj-elasticsearch.config=$APP_CONF_FILE -Ducoinj.launch.mode=full -Djna.nosys=true -Des.http.cors.allow-origin=* -jar ucoinj-elasticsearch-plugin-${project.version}.jar $*
exitcode=$? exitcode=$?
echo "Stop ${project.name} with exitcode: $exitcode" echo "Stop ${project.name} with exitcode: $exitcode"
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
# By default: false # By default: false
#ucoinj.elasticsearch.embedded.enable=true #ucoinj.elasticsearch.embedded.enable=true
# If not embedded: ES Node Host # ES Node Host
# Could be override using option : '-esh <host>' # THe node to connect (if NOT embedded node)
#ucoinj.elasticsearch.host=192.168.0.5 # By default: 'localhost'
#ucoinj.elasticsearch.host=<ES_Node_IP>
# If not embedded: ES Node Port # If not embedded: ES Node Port
# Could be override using option : '-esp <port>' # Could be override using option : '-esp <port>'
...@@ -43,3 +44,11 @@ ...@@ -43,3 +44,11 @@
# See ES config 'http.enable' # See ES config 'http.enable'
#ucoinj.elasticsearch.http.enable=false #ucoinj.elasticsearch.http.enable=false
# ES Node Network Host (if http enable)
# Allow values : (see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html)
# any IP address, or 'localhost'
# _[networkInterface]_ for addresses of a network interface, for example _eth0_ or _en0_.
# _local_ for any loopback addresses on the system
#
# By default: '_local_'
#ucoinj.elasticsearch.network.host=_eth0_
# Global logging configuration # Global logging configuration
#log4j.rootLogger=ERROR, stdout, file log4j.rootLogger=ERROR, stdout, file
log4j.rootLogger=ERROR, stdout #log4j.rootLogger=ERROR, stdout
# Console output # Console output
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout=org.apache.log4j.ConsoleAppender
......
...@@ -110,7 +110,16 @@ public class Main { ...@@ -110,7 +110,16 @@ public class Main {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
if (!config.isDaemon()) { if (config.isDaemon()) {
while (true) {
try {
Thread.sleep(5000);
} catch(InterruptedException e) {
// Nothing
}
}
}
else {
if (arguments.size() > 0) { if (arguments.size() > 0) {
// Check if auto-quit if need // Check if auto-quit if need
...@@ -135,12 +144,10 @@ public class Main { ...@@ -135,12 +144,10 @@ public class Main {
} }
} }
} }
}
// shutdown // shutdown
shutdown(); shutdown();
log.info("uCoinj :: ElasticSearch Indexer successfully stopped");
}
} }
/* -- protected methods -- */ /* -- protected methods -- */
...@@ -157,6 +164,8 @@ public class Main { ...@@ -157,6 +164,8 @@ public class Main {
// Silent is gold // Silent is gold
} }
} }
log.info("uCoinj :: ElasticSearch Indexer successfully stopped");
} }
protected void initI18n(Configuration config) throws IOException { protected void initI18n(Configuration config) throws IOException {
......
...@@ -257,6 +257,10 @@ public class Configuration { ...@@ -257,6 +257,10 @@ public class Configuration {
return applicationConfig.getOption(ConfigurationOption.HOST.getKey()); return applicationConfig.getOption(ConfigurationOption.HOST.getKey());
} }
public String getNetworkHost() {
return applicationConfig.getOption(ConfigurationOption.NETWORK_HOST.getKey());
}
public int getPort() { public int getPort() {
return applicationConfig.getOptionAsInt(ConfigurationOption.PORT.getKey()); return applicationConfig.getOptionAsInt(ConfigurationOption.PORT.getKey());
} }
......
...@@ -129,6 +129,13 @@ public enum ConfigurationOption implements ConfigOptionDef { ...@@ -129,6 +129,13 @@ public enum ConfigurationOption implements ConfigOptionDef {
Integer.class, Integer.class,
false), false),
NETWORK_HOST(
"ucoinj.elasticsearch.network.host",
n("ucoinj.config.option.elasticsearch.network.host.description"),
"_local_",
String.class,
false),
DAEMON( DAEMON(
"ucoinj.elasticsearch.daemon", "ucoinj.elasticsearch.daemon",
n("ucoinj.config.option.node.elasticsearch.daemon.description"), n("ucoinj.config.option.node.elasticsearch.daemon.description"),
......
...@@ -187,20 +187,21 @@ public class ElasticSearchService implements Bean,InitializingBean, Closeable { ...@@ -187,20 +187,21 @@ public class ElasticSearchService implements Bean,InitializingBean, Closeable {
.put("path.home", config.getBasedir()) .put("path.home", config.getBasedir())
.put("path.data", config.getDataDirectory()) .put("path.data", config.getDataDirectory())
.put("path.plugins", config.getPluginsDirectory()) .put("path.plugins", config.getPluginsDirectory())
// TODO .put("http.host", config.getHost())
.put("http.cors.enabled", Boolean.TRUE.toString()); .put("http.cors.enabled", Boolean.TRUE.toString());
if (!local && enableHttp && StringUtils.isNotBlank(config.getHost())) {
builder.put("http.host", config.getHost()); // Set network host
if (!"localhost".equalsIgnoreCase(config.getHost())) { if (!local && enableHttp
builder.put("network.host", config.getHost()); && StringUtils.isNotBlank(config.getNetworkHost())) {
if (!"localhost".equalsIgnoreCase(config.getNetworkHost())) {
builder.put("network.host", config.getNetworkHost());
} }
} }
Settings settings = builder.build();
// Create a node builder // Create a node builder
NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder() NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder()
.clusterName(clusterName) .clusterName(clusterName)
.settings(settings) .settings(builder.build())
.local(local); .local(local);
if (StringUtils.isNotBlank(clusterName)) { if (StringUtils.isNotBlank(clusterName)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment