Ejemplo n.º 1
0
func main() {
	flag.Parse()

	oracle, err := server.NewTimestampOracle(*addr)
	if err != nil {
		log.Fatal(err)
	}

	go http.ListenAndServe(":5555", nil)

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-sc
		log.Infof("Got signal [%d] to exit.", sig)
		oracle.Close()
		os.Exit(0)
	}()

	oracle.Run()
}
Ejemplo n.º 2
0
Archivo: main.go Proyecto: pingcap/tso
func main() {
	flag.Parse()

	log.SetLevelByString(*logLevel)

	cfg := &server.Config{
		Addr:         *addr,
		ZKAddr:       *zk,
		RootPath:     *rootPath,
		SaveInterval: *interval,
	}

	oracle, err := server.NewTimestampOracle(cfg)
	if err != nil {
		log.Fatal(err)
	}

	go http.ListenAndServe(":5555", nil)

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-sc
		log.Infof("Got signal [%d] to exit.", sig)
		oracle.Close()
		os.Exit(0)
	}()

	oracle.Run()
}
Ejemplo n.º 3
0
func (s *testClientSuite) testStartServer(c *C) {
	svr, err := server.NewTimestampOracle(*testAddr)
	c.Assert(err, IsNil)

	go svr.Run()
	time.Sleep(100 * time.Millisecond)

	s.server = svr
}
Ejemplo n.º 4
0
func (s *testClientSuite) testStartServer(c *C) {
	s.rootPath = "/zk/test_tso"

	cfg := &server.Config{
		Addr:         "127.0.0.1:0",
		ZKAddr:       *testZK,
		RootPath:     s.rootPath,
		SaveInterval: 100,
	}
	svr, err := server.NewTimestampOracle(cfg)
	c.Assert(err, IsNil)

	cfg.Addr = svr.ListenAddr()

	go svr.Run()
	time.Sleep(100 * time.Millisecond)

	s.server = svr
}