Beispiel #1
0
func main() {
	logger := log.New(os.Stderr, "server", log.LstdFlags)
	if err := serverFlags.Parse(os.Args[1:]); err != nil {
		logger.Fatalf("%v", err)
	}

	u, err := configmap.New(serverFlags, *dirPathWatch, logger)
	if err != nil {
		logger.Fatalf("Failed setting up an updater %v", err)
	}
	err = u.Initialize()
	if err != nil {
		logger.Fatalf("Failed initializing watcher %v", err)
	}
	if err := u.Start(); err != nil {
		logger.Fatalf("Could not start: %v", err)
	}
	logger.Printf("etcd flag value watching initialized")

	flagzEndpoint := flagz.NewStatusEndpoint(serverFlags)
	http.HandleFunc("/debug/flagz", flagzEndpoint.ListFlags)
	http.HandleFunc("/", handleDefaultPage)

	addr := fmt.Sprintf("%s:%d", *listenHost, *listenPort)
	logger.Printf("Serving at: %v", addr)
	if err := http.ListenAndServe(addr, http.DefaultServeMux); err != nil {
		logger.Fatalf("Failed serving: %v", err)
	}
	logger.Printf("Done, bye.")
}
Beispiel #2
0
func (s *updaterTestSuite) SetupTest() {
	var err error
	s.tempDir, err = ioutil.TempDir("/tmp", "updater_test")
	require.NoError(s.T(), err, "failed creating temp directory for testing")
	s.copyTestDataToDir()
	s.linkDataDirTo(firstGoodDir)

	s.flagSet = flag.NewFlagSet("updater_test", flag.ContinueOnError)
	s.dynInt = flagz.DynInt64(s.flagSet, "some_dynint", 1, "dynamic int for testing")
	s.staticInt = s.flagSet.Int32("some_int", 1, "static int for testing")

	s.updater, err = configmap.New(s.flagSet, path.Join(s.tempDir, "testdata"), &testingLog{T: s.T()})
	require.NoError(s.T(), err, "creating a config map must not fail")
}