forked from ablegao/nsq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nsqlookupd.go
59 lines (47 loc) · 1.72 KB
/
nsqlookupd.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
51
52
53
54
55
56
57
58
59
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/BurntSushi/toml"
"github.com/bitly/nsq/nsqlookupd"
"github.com/bitly/nsq/util"
"github.com/mreiferson/go-options"
)
var (
flagSet = flag.NewFlagSet("nsqlookupd", flag.ExitOnError)
config = flagSet.String("config", "", "path to config file")
showVersion = flagSet.Bool("version", false, "print version string")
verbose = flagSet.Bool("verbose", false, "enable verbose logging")
tcpAddress = flagSet.String("tcp-address", "0.0.0.0:4160", "<addr>:<port> to listen on for TCP clients")
httpAddress = flagSet.String("http-address", "0.0.0.0:4161", "<addr>:<port> to listen on for HTTP clients")
broadcastAddress = flagSet.String("broadcast-address", "", "address of this lookupd node, (default to the OS hostname)")
inactiveProducerTimeout = flagSet.Duration("inactive-producer-timeout", 300*time.Second, "duration of time a producer will remain in the active list since its last ping")
tombstoneLifetime = flagSet.Duration("tombstone-lifetime", 45*time.Second, "duration of time a producer will remain tombstoned if registration remains")
)
func main() {
flagSet.Parse(os.Args[1:])
if *showVersion {
fmt.Println(util.Version("nsqlookupd"))
return
}
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
var cfg map[string]interface{}
if *config != "" {
_, err := toml.DecodeFile(*config, &cfg)
if err != nil {
log.Fatalf("ERROR: failed to load config file %s - %s", *config, err.Error())
}
}
opts := nsqlookupd.NewNSQLookupdOptions()
options.Resolve(opts, flagSet, cfg)
daemon := nsqlookupd.NewNSQLookupd(opts)
daemon.Main()
<-signalChan
daemon.Exit()
}