예제 #1
0
func main() {
	flag.Parse()

	if *flagIndex < 0 {
		fatalf("Index of dashboard should be specified")
	}

	config, err := config.Read(*flagConfig)
	if err != nil {
		fatalf("read config (%s)", err)
	}
	t := &worker{}

	// Create transport layer
	here := config.Dashboard[*flagIndex]

	// Created embedded DB server
	dialer := tcp.NewDialer()
	if t.srv, err = dashboard.NewServer(dialer, config.Timeline, *flagLevelDB, *flagCache*1e6); err != nil {
		panic(err)
	}

	t.fwd = newForwarder(dialer, config.Dashboard, here, t.srv)

	// Accept intra-cluster forward requests in a loop
	t.fwdch = StreamForwardRequests(tcp.NewListener(here.Addr))

	// Accept API requests
	t.apich = StreamAPIRequests(here.HTTP)

	t.schedule()
}
예제 #2
0
func main() {
	flag.Parse()

	if *flagIndex < 0 {
		fatalf("Index of timeline should be specified")
	}

	config, err := config.Read(*flagConfig)
	if err != nil {
		fatalf("read config (%s)", err)
	}
	t := &worker{}

	var filter Filter
	if *flagFilter != "" {
		if filter, err = ParseFilter(*flagFilter); err != nil {
			fatalf("Error parsing filter (%s)\n", err)
		}
		if len(filter) == 0 {
			fatalf("Empty filter")
		}
	}

	// Created embedded DB server
	if t.srv, err = timeline.NewServer(*flagLevelDB, *flagCache*1e6); err != nil {
		panic(err)
	}

	here := config.Timeline[*flagIndex]
	t.fwd = newForwarder(tcp.NewDialer(), config.Timeline, here, t.srv, filter)

	t.xCreate, t.xQuery = StreamX(tcp.NewListener(here.Addr))
	t.hCreate, t.hQuery = StreamHTTP(here.HTTP)
	if !*flagFire {
		t.fCreate = StreamFirehose(config.Firehose)
	}

	t.schedule()
}