mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
elasticsearch: add 5.x package, service
This commit is contained in:
parent
6a29327175
commit
47d038c21d
5 changed files with 168 additions and 18 deletions
|
@ -5,13 +5,22 @@ with lib;
|
|||
let
|
||||
cfg = config.services.elasticsearch;
|
||||
|
||||
es5 = builtins.compareVersions (builtins.parseDrvName cfg.package.name).version "5" >= 0;
|
||||
|
||||
esConfig = ''
|
||||
network.host: ${cfg.listenAddress}
|
||||
network.port: ${toString cfg.port}
|
||||
network.tcp.port: ${toString cfg.tcp_port}
|
||||
# TODO: find a way to enable security manager
|
||||
security.manager.enabled: false
|
||||
cluster.name: ${cfg.cluster_name}
|
||||
|
||||
${if es5 then ''
|
||||
http.port: ${toString cfg.port}
|
||||
transport.tcp.port: ${toString cfg.tcp_port}
|
||||
'' else ''
|
||||
network.port: ${toString cfg.port}
|
||||
network.tcp.port: ${toString cfg.tcp_port}
|
||||
# TODO: find a way to enable security manager
|
||||
security.manager.enabled: false
|
||||
''}
|
||||
|
||||
${cfg.extraConf}
|
||||
'';
|
||||
|
||||
|
@ -19,13 +28,18 @@ let
|
|||
name = "elasticsearch-config";
|
||||
paths = [
|
||||
(pkgs.writeTextDir "elasticsearch.yml" esConfig)
|
||||
(pkgs.writeTextDir "logging.yml" cfg.logging)
|
||||
(if es5 then (pkgs.writeTextDir "log4j2.properties" cfg.logging)
|
||||
else (pkgs.writeTextDir "logging.yml" cfg.logging))
|
||||
];
|
||||
# Elasticsearch 5.x won't start when the scripts directory does not exist
|
||||
postBuild = if es5 then "${pkgs.coreutils}/bin/mkdir -p $out/scripts" else "";
|
||||
};
|
||||
|
||||
esPlugins = pkgs.buildEnv {
|
||||
name = "elasticsearch-plugins";
|
||||
paths = cfg.plugins;
|
||||
# Elasticsearch 5.x won't start when the plugins directory does not exist
|
||||
postBuild = if es5 then "${pkgs.coreutils}/bin/mkdir -p $out/plugins" else "";
|
||||
};
|
||||
|
||||
in {
|
||||
|
@ -85,18 +99,30 @@ in {
|
|||
|
||||
logging = mkOption {
|
||||
description = "Elasticsearch logging configuration.";
|
||||
default = ''
|
||||
rootLogger: INFO, console
|
||||
logger:
|
||||
action: INFO
|
||||
com.amazonaws: WARN
|
||||
appender:
|
||||
console:
|
||||
type: console
|
||||
layout:
|
||||
type: consolePattern
|
||||
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
|
||||
'';
|
||||
default =
|
||||
if es5 then ''
|
||||
logger.action.name = org.elasticsearch.action
|
||||
logger.action.level = info
|
||||
|
||||
appender.console.type = Console
|
||||
appender.console.name = console
|
||||
appender.console.layout.type = PatternLayout
|
||||
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
|
||||
|
||||
rootLogger.level = info
|
||||
rootLogger.appenderRef.console.ref = console
|
||||
'' else ''
|
||||
rootLogger: INFO, console
|
||||
logger:
|
||||
action: INFO
|
||||
com.amazonaws: WARN
|
||||
appender:
|
||||
console:
|
||||
type: console
|
||||
layout:
|
||||
type: consolePattern
|
||||
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
|
@ -112,6 +138,12 @@ in {
|
|||
description = "Extra command line options for the elasticsearch launcher.";
|
||||
default = [];
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
|
||||
extraJavaOptions = mkOption {
|
||||
description = "Extra command line options for Java.";
|
||||
default = [];
|
||||
type = types.listOf types.str;
|
||||
example = [ "-Djava.net.preferIPv4Stack=true" ];
|
||||
};
|
||||
|
||||
|
@ -133,13 +165,21 @@ in {
|
|||
path = [ pkgs.inetutils ];
|
||||
environment = {
|
||||
ES_HOME = cfg.dataDir;
|
||||
ES_JAVA_OPTS = toString ([ "-Des.path.conf=${configDir}" ] ++ cfg.extraJavaOptions);
|
||||
};
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/elasticsearch -Des.path.conf=${configDir} ${toString cfg.extraCmdLineOptions}";
|
||||
ExecStart = "${cfg.package}/bin/elasticsearch ${toString cfg.extraCmdLineOptions}";
|
||||
User = "elasticsearch";
|
||||
PermissionsStartOnly = true;
|
||||
LimitNOFILE = "1024000";
|
||||
};
|
||||
preStart = ''
|
||||
# Only set vm.max_map_count if lower than ES required minimum
|
||||
# This avoids conflict if configured via boot.kernel.sysctl
|
||||
if [ `${pkgs.procps}/bin/sysctl -n vm.max_map_count` -lt 262144 ]; then
|
||||
${pkgs.procps}/bin/sysctl -w vm.max_map_count=262144
|
||||
fi
|
||||
|
||||
mkdir -m 0700 -p ${cfg.dataDir}
|
||||
|
||||
# Install plugins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue