-
Notifications
You must be signed in to change notification settings - Fork 38
/
main.go
50 lines (38 loc) · 953 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"os"
elastigo "github.com/jacqui/elastigo/lib"
"github.com/nytlabs/hive/hive"
)
var (
port = flag.String("port", "8080", "hive port")
esDomain = flag.String("esDomain", "localhost", "elasticsearch domain")
esPort = flag.String("esPort", "9200", "elasticsearch port")
index = flag.String("index", "hive", "elasticsearch index name")
)
func main() {
flag.Parse()
s := hive.NewServer()
// what port should the hive server run on
s.Port = *port
// allow overriding elasticsearch index name
// this is useful for testing
s.Index = *index
conn := elastigo.NewConn()
// EnvVar set via etcd/fleet
esDomainEnv := os.Getenv("ELASTICSEARCH_DOMAIN")
esPortEnv := os.Getenv("ELASTICSEARCH_PORT")
if esDomainEnv != "" {
conn.Domain = esDomainEnv
} else {
conn.Domain = *esDomain
}
if esPortEnv != "" {
conn.Port = esPortEnv
} else {
conn.Port = *esPort
}
s.EsConn = *conn
s.Run()
}