Remove working directory

This commit removes the working directory and its associated environment variable "WORK_DIR"
This commit is contained in:
Tanguy Leroux 2015-04-20 11:31:01 +02:00
parent 1db380cf49
commit f7d4baacfb
16 changed files with 8 additions and 90 deletions

View File

@ -137,13 +137,11 @@ set JVM_SS=256
if "%DATA_DIR%" == "" set DATA_DIR=%ES_HOME%\data if "%DATA_DIR%" == "" set DATA_DIR=%ES_HOME%\data
if "%WORK_DIR%" == "" set WORK_DIR=%ES_HOME%
if "%CONF_DIR%" == "" set CONF_DIR=%ES_HOME%\config if "%CONF_DIR%" == "" set CONF_DIR=%ES_HOME%\config
if "%CONF_FILE%" == "" set CONF_FILE=%ES_HOME%\config\elasticsearch.yml if "%CONF_FILE%" == "" set CONF_FILE=%ES_HOME%\config\elasticsearch.yml
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%" 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.conf="%CONF_DIR%"
set JVM_OPTS=%JAVA_OPTS: =;% set JVM_OPTS=%JAVA_OPTS: =;%

View File

@ -154,10 +154,6 @@
# #
#path.data: /path/to/data1,/path/to/data2 #path.data: /path/to/data1,/path/to/data2
# Path to temporary files:
#
#path.work: /path/to/work
# Path to log files: # Path to log files:
# #
#path.logs: /path/to/logs #path.logs: /path/to/logs

View File

@ -21,7 +21,6 @@ Each package features a configuration file, which allows you to set the followin
`MAX_MAP_COUNT`:: Maximum number of memory map areas a process may have. If you use `mmapfs` as index store type, make sure this is set to a high value. For more information, check the https://github.com/torvalds/linux/blob/master/Documentation/sysctl/vm.txt[linux kernel documentation] about `max_map_count`. This is set via `sysctl` before starting elasticsearch. Defaults to `65535` `MAX_MAP_COUNT`:: Maximum number of memory map areas a process may have. If you use `mmapfs` as index store type, make sure this is set to a high value. For more information, check the https://github.com/torvalds/linux/blob/master/Documentation/sysctl/vm.txt[linux kernel documentation] about `max_map_count`. This is set via `sysctl` before starting elasticsearch. Defaults to `65535`
`LOG_DIR`:: Log directory, defaults to `/var/log/elasticsearch` `LOG_DIR`:: Log directory, defaults to `/var/log/elasticsearch`
`DATA_DIR`:: Data directory, defaults to `/var/lib/elasticsearch` `DATA_DIR`:: Data directory, defaults to `/var/lib/elasticsearch`
`WORK_DIR`:: Work directory, defaults to `/tmp/elasticsearch`
`CONF_DIR`:: Configuration file directory (which needs to include `elasticsearch.yml` and `logging.yml` files), defaults to `/etc/elasticsearch` `CONF_DIR`:: Configuration file directory (which needs to include `elasticsearch.yml` and `logging.yml` files), defaults to `/etc/elasticsearch`
`CONF_FILE`:: Path to configuration file, defaults to `/etc/elasticsearch/elasticsearch.yml` `CONF_FILE`:: Path to configuration file, defaults to `/etc/elasticsearch/elasticsearch.yml`
`ES_JAVA_OPTS`:: Any additional java options you may want to apply. This may be useful, if you need to set the `node.name` property, but do not want to change the `elasticsearch.yml` configuration file, because it is distributed via a provisioning system like puppet or chef. Example: `ES_JAVA_OPTS="-Des.node.name=search-01"` `ES_JAVA_OPTS`:: Any additional java options you may want to apply. This may be useful, if you need to set the `node.name` property, but do not want to change the `elasticsearch.yml` configuration file, because it is distributed via a provisioning system like puppet or chef. Example: `ES_JAVA_OPTS="-Des.node.name=search-01"`

View File

@ -57,7 +57,6 @@
<packaging.elasticsearch.data.dir>/var/lib/elasticsearch</packaging.elasticsearch.data.dir> <packaging.elasticsearch.data.dir>/var/lib/elasticsearch</packaging.elasticsearch.data.dir>
<packaging.elasticsearch.user>elasticsearch</packaging.elasticsearch.user> <packaging.elasticsearch.user>elasticsearch</packaging.elasticsearch.user>
<packaging.elasticsearch.group>elasticsearch</packaging.elasticsearch.group> <packaging.elasticsearch.group>elasticsearch</packaging.elasticsearch.group>
<packaging.elasticsearch.work.dir>/tmp/elasticsearch</packaging.elasticsearch.work.dir>
<packaging.elasticsearch.log.dir>/var/log/elasticsearch</packaging.elasticsearch.log.dir> <packaging.elasticsearch.log.dir>/var/log/elasticsearch</packaging.elasticsearch.log.dir>
<packaging.elasticsearch.plugins.dir>${packaging.elasticsearch.home.dir}/plugins</packaging.elasticsearch.plugins.dir> <packaging.elasticsearch.plugins.dir>${packaging.elasticsearch.home.dir}/plugins</packaging.elasticsearch.plugins.dir>
<packaging.elasticsearch.pid.dir>/var/run/elasticsearch</packaging.elasticsearch.pid.dir> <packaging.elasticsearch.pid.dir>/var/run/elasticsearch</packaging.elasticsearch.pid.dir>
@ -1210,7 +1209,6 @@
<paths> <paths>
<path>${packaging.elasticsearch.data.dir}</path> <path>${packaging.elasticsearch.data.dir}</path>
<path>${packaging.elasticsearch.log.dir}</path> <path>${packaging.elasticsearch.log.dir}</path>
<path>${packaging.elasticsearch.work.dir}</path>
<path>${packaging.elasticsearch.plugins.dir}</path> <path>${packaging.elasticsearch.plugins.dir}</path>
<path>${packaging.elasticsearch.pid.dir}</path> <path>${packaging.elasticsearch.pid.dir}</path>
</paths> </paths>
@ -1408,12 +1406,6 @@
<username>${packaging.elasticsearch.user}</username> <username>${packaging.elasticsearch.user}</username>
<groupname>${packaging.elasticsearch.group}</groupname> <groupname>${packaging.elasticsearch.group}</groupname>
</mapping> </mapping>
<mapping>
<directory>${packaging.elasticsearch.work.dir}</directory>
<filemode>755</filemode>
<username>${packaging.elasticsearch.user}</username>
<groupname>${packaging.elasticsearch.group}</groupname>
</mapping>
<mapping> <mapping>
<directory>${packaging.elasticsearch.plugins.dir}</directory> <directory>${packaging.elasticsearch.plugins.dir}</directory>
<filemode>755</filemode> <filemode>755</filemode>

View File

@ -20,19 +20,11 @@
package org.elasticsearch.bootstrap; package org.elasticsearch.bootstrap;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.StringHelper; import org.apache.lucene.util.StringHelper;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import java.io.BufferedInputStream; import java.io.*;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.NoSuchFileException; import java.nio.file.NoSuchFileException;
@ -83,8 +75,6 @@ class Security {
paths.add(environment.configFile()); paths.add(environment.configFile());
paths.add(environment.logsFile()); paths.add(environment.logsFile());
paths.add(environment.pluginsFile()); paths.add(environment.pluginsFile());
paths.add(environment.workFile());
paths.add(environment.workWithClusterFile());
for (Path path : environment.dataFiles()) { for (Path path : environment.dataFiles()) {
paths.add(path); paths.add(path);
} }

View File

@ -43,10 +43,6 @@ public class Environment {
private final Path homeFile; private final Path homeFile;
private final Path workFile;
private final Path workWithClusterFile;
private final Path[] dataFiles; private final Path[] dataFiles;
private final Path[] dataWithClusterFiles; private final Path[] dataWithClusterFiles;
@ -97,13 +93,6 @@ public class Environment {
pluginsFile = homeFile.resolve("plugins"); pluginsFile = homeFile.resolve("plugins");
} }
if (settings.get("path.work") != null) {
workFile = PathUtils.get(cleanPath(settings.get("path.work")));
} else {
workFile = homeFile.resolve("work");
}
workWithClusterFile = workFile.resolve(ClusterName.clusterNameFromSettings(settings).value());
String[] dataPaths = settings.getAsArray("path.data"); String[] dataPaths = settings.getAsArray("path.data");
if (dataPaths.length > 0) { if (dataPaths.length > 0) {
dataFiles = new Path[dataPaths.length]; dataFiles = new Path[dataPaths.length];
@ -138,26 +127,6 @@ public class Environment {
return homeFile; return homeFile;
} }
/**
* The work location, path to temp files.
*
* Note, currently, we don't use it in ES at all, we should strive to see if we can keep it like that,
* but if we do, we have the infra for it.
*/
public Path workFile() {
return workFile;
}
/**
* The work location with the cluster name as a sub directory.
*
* Note, currently, we don't use it in ES at all, we should strive to see if we can keep it like that,
* but if we do, we have the infra for it.
*/
public Path workWithClusterFile() {
return workWithClusterFile;
}
/** /**
* The data location. * The data location.
*/ */

View File

@ -143,9 +143,8 @@ public class Node implements Releasable {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
Environment env = tuple.v2(); Environment env = tuple.v2();
logger.debug("using home [{}], config [{}], data [{}], logs [{}], work [{}], plugins [{}]", logger.debug("using home [{}], config [{}], data [{}], logs [{}], plugins [{}]",
env.homeFile(), env.configFile(), Arrays.toString(env.dataFiles()), env.logsFile(), env.homeFile(), env.configFile(), Arrays.toString(env.dataFiles()), env.logsFile(), env.pluginsFile());
env.workFile(), env.pluginsFile());
} }
this.pluginsService = new PluginsService(tuple.v1(), tuple.v2()); this.pluginsService = new PluginsService(tuple.v1(), tuple.v2());

View File

@ -17,9 +17,6 @@
# Elasticsearch logs directory # Elasticsearch logs directory
#LOG_DIR=${packaging.elasticsearch.log.dir} #LOG_DIR=${packaging.elasticsearch.log.dir}
# Elasticsearch work directory
#WORK_DIR=${packaging.elasticsearch.work.dir}
# Elasticsearch PID directory # Elasticsearch PID directory
#PID_DIR=${packaging.elasticsearch.pid.dir} #PID_DIR=${packaging.elasticsearch.pid.dir}

View File

@ -54,7 +54,6 @@ esac
ES_USER="${packaging.elasticsearch.user}" ES_USER="${packaging.elasticsearch.user}"
ES_GROUP="${packaging.elasticsearch.group}" ES_GROUP="${packaging.elasticsearch.group}"
LOG_DIR="${packaging.elasticsearch.log.dir}" LOG_DIR="${packaging.elasticsearch.log.dir}"
WORK_DIR="${packaging.elasticsearch.work.dir}"
PLUGINS_DIR="${packaging.elasticsearch.plugins.dir}" PLUGINS_DIR="${packaging.elasticsearch.plugins.dir}"
PID_DIR="${packaging.elasticsearch.pid.dir}" PID_DIR="${packaging.elasticsearch.pid.dir}"
DATA_DIR="${packaging.elasticsearch.data.dir}" DATA_DIR="${packaging.elasticsearch.data.dir}"
@ -89,12 +88,6 @@ if [ "$REMOVE_DIRS" = "true" ]; then
echo " OK" echo " OK"
fi fi
if [ -d "$WORK_DIR" ]; then
echo -n "Deleting work directory..."
rm -rf "$WORK_DIR"
echo " OK"
fi
if [ -d "$PLUGINS_DIR" ]; then if [ -d "$PLUGINS_DIR" ]; then
echo -n "Deleting plugins directory..." echo -n "Deleting plugins directory..."
rm -rf "$PLUGINS_DIR" rm -rf "$PLUGINS_DIR"

View File

@ -82,9 +82,6 @@ LOG_DIR=/var/log/$NAME
# Elasticsearch data directory # Elasticsearch data directory
DATA_DIR=/var/lib/$NAME DATA_DIR=/var/lib/$NAME
# Elasticsearch work directory
WORK_DIR=/tmp/$NAME
# Elasticsearch configuration directory # Elasticsearch configuration directory
CONF_DIR=/etc/$NAME CONF_DIR=/etc/$NAME
@ -107,7 +104,7 @@ fi
# Define other required variables # Define other required variables
PID_FILE=/var/run/$NAME.pid PID_FILE=/var/run/$NAME.pid
DAEMON=$ES_HOME/bin/elasticsearch DAEMON=$ES_HOME/bin/elasticsearch
DAEMON_OPTS="-d -p $PID_FILE --default.config=$CONF_FILE --default.path.home=$ES_HOME --default.path.logs=$LOG_DIR --default.path.data=$DATA_DIR --default.path.work=$WORK_DIR --default.path.conf=$CONF_DIR" DAEMON_OPTS="-d -p $PID_FILE --default.config=$CONF_FILE --default.path.home=$ES_HOME --default.path.logs=$LOG_DIR --default.path.data=$DATA_DIR --default.path.conf=$CONF_DIR"
export ES_HEAP_SIZE export ES_HEAP_SIZE
export ES_HEAP_NEWSIZE export ES_HEAP_NEWSIZE
@ -150,7 +147,7 @@ case "$1" in
fi fi
# Prepare environment # Prepare environment
mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR"
touch "$PID_FILE" && chown "$ES_USER":"$ES_GROUP" "$PID_FILE" touch "$PID_FILE" && chown "$ES_USER":"$ES_GROUP" "$PID_FILE"
if [ -n "$MAX_OPEN_FILES" ]; then if [ -n "$MAX_OPEN_FILES" ]; then

View File

@ -9,7 +9,6 @@ Environment=CONF_FILE=${packaging.elasticsearch.conf.dir}/elasticsearch.yml
Environment=ES_HOME=${packaging.elasticsearch.home.dir} Environment=ES_HOME=${packaging.elasticsearch.home.dir}
Environment=LOG_DIR=${packaging.elasticsearch.log.dir} Environment=LOG_DIR=${packaging.elasticsearch.log.dir}
Environment=DATA_DIR=${packaging.elasticsearch.data.dir} Environment=DATA_DIR=${packaging.elasticsearch.data.dir}
Environment=WORK_DIR=${packaging.elasticsearch.work.dir}
Environment=CONF_DIR=${packaging.elasticsearch.conf.dir} Environment=CONF_DIR=${packaging.elasticsearch.conf.dir}
EnvironmentFile=-${packaging.env.file} EnvironmentFile=-${packaging.env.file}
User=elasticsearch User=elasticsearch
@ -19,7 +18,6 @@ ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
-Des.default.path.home=$ES_HOME \ -Des.default.path.home=$ES_HOME \
-Des.default.path.logs=$LOG_DIR \ -Des.default.path.logs=$LOG_DIR \
-Des.default.path.data=$DATA_DIR \ -Des.default.path.data=$DATA_DIR \
-Des.default.path.work=$WORK_DIR \
-Des.default.path.conf=$CONF_DIR -Des.default.path.conf=$CONF_DIR
# See MAX_OPEN_FILES in sysconfig # See MAX_OPEN_FILES in sysconfig
LimitNOFILE=65535 LimitNOFILE=65535

View File

@ -39,7 +39,6 @@ MAX_OPEN_FILES=${packaging.os.max.open.files}
MAX_MAP_COUNT=${packaging.os.max.map.count} MAX_MAP_COUNT=${packaging.os.max.map.count}
LOG_DIR="${packaging.elasticsearch.log.dir}" LOG_DIR="${packaging.elasticsearch.log.dir}"
DATA_DIR="${packaging.elasticsearch.data.dir}" DATA_DIR="${packaging.elasticsearch.data.dir}"
WORK_DIR="${packaging.elasticsearch.work.dir}"
CONF_DIR="${packaging.elasticsearch.conf.dir}" CONF_DIR="${packaging.elasticsearch.conf.dir}"
CONF_FILE="${packaging.elasticsearch.conf.dir}/elasticsearch.yml" CONF_FILE="${packaging.elasticsearch.conf.dir}/elasticsearch.yml"
@ -97,15 +96,11 @@ start() {
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
fi fi
if [ -n "$WORK_DIR" ]; then
mkdir -p "$WORK_DIR"
chown "$ES_USER":"$ES_GROUP" "$WORK_DIR"
fi
export ES_GC_LOG_FILE export ES_GC_LOG_FILE
echo -n $"Starting $prog: " echo -n $"Starting $prog: "
# if not running, start it up here, usually something like "daemon $exec" # if not running, start it up here, usually something like "daemon $exec"
daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -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 daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.conf=$CONF_DIR
retval=$? retval=$?
echo echo
[ $retval -eq 0 ] && touch $lockfile [ $retval -eq 0 ] && touch $lockfile

View File

@ -8,13 +8,12 @@ Environment=CONF_FILE=${packaging.elasticsearch.conf.dir}/elasticsearch.yml
Environment=ES_HOME=${packaging.elasticsearch.home.dir} Environment=ES_HOME=${packaging.elasticsearch.home.dir}
Environment=LOG_DIR=${packaging.elasticsearch.log.dir} Environment=LOG_DIR=${packaging.elasticsearch.log.dir}
Environment=DATA_DIR=${packaging.elasticsearch.data.dir} Environment=DATA_DIR=${packaging.elasticsearch.data.dir}
Environment=WORK_DIR=${packaging.elasticsearch.work.dir}
Environment=CONF_DIR=${packaging.elasticsearch.conf.dir} Environment=CONF_DIR=${packaging.elasticsearch.conf.dir}
EnvironmentFile=-${packaging.env.file} EnvironmentFile=-${packaging.env.file}
User=elasticsearch User=elasticsearch
Group=elasticsearch Group=elasticsearch
PIDFile=/var/run/elasticsearch/elasticsearch.pid PIDFile=/var/run/elasticsearch/elasticsearch.pid
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -d -p /var/run/elasticsearch/elasticsearch.pid -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 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -d -p /var/run/elasticsearch/elasticsearch.pid -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.conf=$CONF_DIR
# See MAX_OPEN_FILES in sysconfig # See MAX_OPEN_FILES in sysconfig
LimitNOFILE=65535 LimitNOFILE=65535
# See MAX_LOCKED_MEMORY in sysconfig, use "infinity" when MAX_LOCKED_MEMORY=unlimited and using bootstrap.mlockall: true # See MAX_LOCKED_MEMORY in sysconfig, use "infinity" when MAX_LOCKED_MEMORY=unlimited and using bootstrap.mlockall: true

View File

@ -128,7 +128,6 @@ setup() {
# Those directories are deleted when removing the package # Those directories are deleted when removing the package
# see postrm file # see postrm file
assert_file_not_exist "/var/log/elasticsearch" assert_file_not_exist "/var/log/elasticsearch"
assert_file_not_exist "/tmp/elasticsearch"
assert_file_not_exist "/usr/share/elasticsearch/plugins" assert_file_not_exist "/usr/share/elasticsearch/plugins"
assert_file_not_exist "/var/run/elasticsearch" assert_file_not_exist "/var/run/elasticsearch"

View File

@ -126,7 +126,6 @@ setup() {
# Those directories are deleted when removing the package # Those directories are deleted when removing the package
# see postrm file # see postrm file
assert_file_not_exist "/var/log/elasticsearch" assert_file_not_exist "/var/log/elasticsearch"
assert_file_not_exist "/tmp/elasticsearch"
assert_file_not_exist "/usr/share/elasticsearch/plugins" assert_file_not_exist "/usr/share/elasticsearch/plugins"
assert_file_not_exist "/var/run/elasticsearch" assert_file_not_exist "/var/run/elasticsearch"

View File

@ -192,8 +192,6 @@ verify_package_installation() {
assert_file "/var/lib/elasticsearch" d elasticsearch 755 assert_file "/var/lib/elasticsearch" d elasticsearch 755
# Log dir # Log dir
assert_file "/var/log/elasticsearch" d elasticsearch 755 assert_file "/var/log/elasticsearch" d elasticsearch 755
# Work dir
assert_file "/tmp/elasticsearch" d elasticsearch 755
# Plugins dir # Plugins dir
assert_file "/usr/share/elasticsearch/plugins" d elasticsearch 755 assert_file "/usr/share/elasticsearch/plugins" d elasticsearch 755
# PID dir # PID dir