fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

indexserver: Read NODE_NAME envvar for hostname

The HOSTNAME environment variable is confusing when configured in docker
environments, since the HOSTNAME we want to set is not the indexserver's
hostname, but the webserver's hostname. Instead we make it possible to use
NODE_NAME to make the docker configuration clearer. We still support
specifying HOSTNAME as an environment variable, but NODE_NAME takes priority.

We do not change the command line flag since it is already in use. We also
expect docker users to configure via environment variables, not command line
flags.

Fixes https://github.com/sourcegraph/sourcegraph/issues/6846

Change-Id: I9bfcb9163d4df8675a6087e981fa702a3968338f

+4 -1
+4 -1
cmd/zoekt-sourcegraph-indexserver/main.go
··· 520 520 } 521 521 522 522 func hostnameBestEffort() string { 523 + if h := os.Getenv("NODE_NAME"); h != "" { 524 + return h 525 + } 523 526 if h := os.Getenv("HOSTNAME"); h != "" { 524 527 return h 525 528 } ··· 532 535 interval := flag.Duration("interval", 10*time.Minute, "sync with sourcegraph this often") 533 536 index := flag.String("index", build.DefaultDir, "set index directory to use") 534 537 listen := flag.String("listen", "", "listen on this address.") 535 - hostname := flag.String("hostname", hostnameBestEffort(), "the name we advertise to Sourcegraph when asking for the list of repositories to index. Can also be set via the HOSTNAME environment variable.") 538 + hostname := flag.String("hostname", hostnameBestEffort(), "the name we advertise to Sourcegraph when asking for the list of repositories to index. Can also be set via the NODE_NAME environment variable.") 536 539 cpuFraction := flag.Float64("cpu_fraction", 0.25, 537 540 "use this fraction of the cores for indexing.") 538 541 dbg := flag.Bool("debug", false,