Browse Source

Export the hostname as environment variable and mention it in the docs

André Hänsel 10 years ago
parent
commit
c107f0bcb9
3 changed files with 15 additions and 0 deletions
  1. 2 0
      bin/elasticsearch
  2. 2 0
      bin/elasticsearch.bat
  3. 11 0
      docs/reference/setup/configuration.asciidoc

+ 2 - 0
bin/elasticsearch

@@ -148,6 +148,8 @@ launch_service()
     LANG=en_US.UTF-8
     LC_ALL=en_US.UTF-8
 
+    export HOSTNAME=`hostname -s`
+
     # The es-foreground option will tell Elasticsearch not to close stdout/stderr, but it's up to us not to daemonize.
     if [ "x$daemonized" = "x" ]; then
         es_parms="$es_parms -Des.foreground=yes"

+ 2 - 0
bin/elasticsearch.bat

@@ -33,6 +33,8 @@ FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO (
 	)
 )
 
+SET HOSTNAME=%COMPUTERNAME%
+
 CALL "%~dp0elasticsearch.in.bat"
 IF ERRORLEVEL 1 (
 	IF NOT DEFINED nopauseonerror (

+ 11 - 0
docs/reference/setup/configuration.asciidoc

@@ -208,6 +208,17 @@ node:
   name: <NAME OF YOUR NODE>
 --------------------------------------------------
 
+The hostname of the machine is provided in an
+environment variable, so you can set the node name
+to the hostname, if on that machine you only run _a
+single elasticsearch node_ for that cluster.
+
+[source,yaml]
+--------------------------------------------------
+node:
+  name: ${HOSTNAME}
+--------------------------------------------------
+
 Internally, all settings are collapsed into "namespaced" settings. For
 example, the above gets collapsed into `node.name`. This means that
 its easy to support other configuration formats, for example,