diff --git a/templates/systemd/elasticsearch.j2 b/templates/systemd/elasticsearch.j2 index ab75b44e4ee96..34d212b21c9db 100644 --- a/templates/systemd/elasticsearch.j2 +++ b/templates/systemd/elasticsearch.j2 @@ -12,9 +12,15 @@ Environment=LOG_DIR={{log_dir}} Environment=PID_DIR={{pid_dir}} EnvironmentFile=-{{instance_default_file}} +WorkingDirectory={{es_home}} + User={{es_user}} Group={{es_group}} +{% if es_version | version_compare('2.0', '>=') %} +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec +{% endif %} + ExecStart={{es_home}}/bin/elasticsearch \ -Des.pidfile=${PID_DIR}/elasticsearch.pid \ -Des.default.path.home=${ES_HOME} \ @@ -24,11 +30,8 @@ ExecStart={{es_home}}/bin/elasticsearch \ -# Connects standard output to /dev/null -StandardOutput=null - -# Connects standard error to journal -StandardError=journal +StandardOutput=journal +StandardError=inherit # Specifies the maximum file descriptor number that can be opened by this process LimitNOFILE={{es_max_open_files}}