Skip to content

Commit

Permalink
refactor: forgot about elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaraj-bh committed Mar 18, 2024
1 parent ccf8305 commit 6c3e490
Showing 1 changed file with 44 additions and 35 deletions.
79 changes: 44 additions & 35 deletions nix/elasticsearch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,41 +141,50 @@ in
postBuild = "${pkgs.coreutils}/bin/mkdir -p $out/plugins";
};

startScript = pkgs.writeShellScript "es-startup" ''
set -e
mkdir -m 0700 -p "${config.dataDir}"
export ES_HOME=$(${pkgs.coreutils}/bin/realpath ${config.dataDir})
export ES_JAVA_OPTS="${toString config.extraJavaOptions}"
export ES_PATH_CONF="${config.dataDir}/config"
# Install plugins
rm -f "${config.dataDir}/plugins"
ln -sf ${esPlugins}/plugins "${config.dataDir}/plugins"
rm -f "${config.dataDir}/lib"
ln -sf ${config.package}/lib "${config.dataDir}/lib"
rm -f "${config.dataDir}/modules"
ln -sf ${config.package}/modules "${config.dataDir}/modules"
# Create config dir
mkdir -m 0700 -p "${config.dataDir}/config"
rm -f "${config.dataDir}/config/elasticsearch.yml"
cp ${elasticsearchYml} "${config.dataDir}/config/elasticsearch.yml"
rm -f "${config.dataDir}/logging.yml"
rm -f "${config.dataDir}/config/${loggingConfigFilename}"
cp ${loggingConfigFile} "${config.dataDir}/config/${loggingConfigFilename}"
mkdir -p "${config.dataDir}/scripts"
rm -f "${config.dataDir}/config/jvm.options"
cp ${config.package}/config/jvm.options "${config.dataDir}/config/jvm.options"
# Create log dir
mkdir -m 0700 -p "${config.dataDir}/logs"
# Start it
exec ${config.package}/bin/elasticsearch ${toString config.extraCmdLineOptions}
'';

startScript = pkgs.writeShellApplication {

name = "es-startup";
runtimeInputs = [ pkgs.coreutils config.package ];
text = ''
set -e
mkdir -p "${config.dataDir}"
chmod 0700 "${config.dataDir}"
ES_HOME=$(${pkgs.coreutils}/bin/realpath ${config.dataDir})
ES_JAVA_OPTS="${toString config.extraJavaOptions}"
ES_PATH_CONF="${config.dataDir}/config"
export ES_HOME ES_JAVA_OPTS ES_PATH_CONF
# Install plugins
rm -f "${config.dataDir}/plugins"
ln -sf ${esPlugins}/plugins "${config.dataDir}/plugins"
rm -f "${config.dataDir}/lib"
ln -sf ${config.package}/lib "${config.dataDir}/lib"
rm -f "${config.dataDir}/modules"
ln -sf ${config.package}/modules "${config.dataDir}/modules"
# Create config dir
mkdir -p "${config.dataDir}/config"
chmod 0700 "${config.dataDir}/config"
rm -f "${config.dataDir}/config/elasticsearch.yml"
cp ${elasticsearchYml} "${config.dataDir}/config/elasticsearch.yml"
rm -f "${config.dataDir}/logging.yml"
rm -f "${config.dataDir}/config/${loggingConfigFilename}"
cp ${loggingConfigFile} "${config.dataDir}/config/${loggingConfigFilename}"
mkdir -p "${config.dataDir}/scripts"
rm -f "${config.dataDir}/config/jvm.options"
cp ${config.package}/config/jvm.options "${config.dataDir}/config/jvm.options"
# Create log dir
mkdir -p "${config.dataDir}/logs"
chmod 0700 "${config.dataDir}/logs"
# Start it
elasticsearch ${toString config.extraCmdLineOptions}

This comment has been minimized.

Copy link
@srid

srid Mar 18, 2024

Member

exec was dropped?

This comment has been minimized.

Copy link
@shivaraj-bh

shivaraj-bh Mar 18, 2024

Author Member

that was a mistake, added it back in b0e1818

'';
};
in
{
command = startScript;
Expand Down

0 comments on commit 6c3e490

Please sign in to comment.