func main() {
	flagSet.Parse(os.Args[1:])

	if *showVersion {
		fmt.Println(util.Version("nsqlookupd"))
		return
	}

	signalChan := make(chan os.Signal, 1)
	exitChan := make(chan int)
	go func() {
		<-signalChan
		exitChan <- 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())
		}
	}

	options := nsqlookupd.NewNSQLookupdOptions()
	util.ResolveOptions(options, flagSet, cfg)
	daemon := nsqlookupd.NewNSQLookupd(options)

	log.Println(util.Version("nsqlookupd"))

	daemon.Main()
	<-exitChan
	daemon.Exit()
}
func main() {
	flagSet.Parse(os.Args[1:])

	rand.Seed(time.Now().UTC().UnixNano())

	if *showVersion {
		fmt.Println(util.Version("nsqd"))
		return
	}

	exitChan := make(chan int)
	signalChan := make(chan os.Signal, 1)
	go func() {
		<-signalChan
		exitChan <- 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())
		}
	}

	options := NewNSQDOptions()
	util.ResolveOptions(options, flagSet, cfg)
	nsqd := NewNSQD(options)

	log.Println(util.Version("nsqd"))
	log.Printf("worker id %d", options.ID)

	nsqd.LoadMetadata()
	err := nsqd.PersistMetadata()
	if err != nil {
		log.Fatalf("ERROR: failed to persist metadata - %s", err.Error())
	}
	nsqd.Main()
	<-exitChan
	nsqd.Exit()
}
func main() {
	flagSet.Parse(os.Args[1:])

	if *showVersion {
		fmt.Println(util.Version("nsqadmin"))
		return
	}

	if *templateDir != "" {
		log.Printf("WARNING: --template-dir is deprecated and will be removed in the next release (templates are now compiled into the binary)")
	}

	exitChan := make(chan int)
	signalChan := make(chan os.Signal, 1)
	go func() {
		<-signalChan
		exitChan <- 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())
		}
	}

	options := NewNSQAdminOptions()
	util.ResolveOptions(options, flagSet, cfg)
	nsqadmin := NewNSQAdmin(options)

	log.Println(util.Version("nsqadmin"))

	nsqadmin.Main()
	<-exitChan
	nsqadmin.Exit()
}