func (s *VESuite) SetUpSuite(c *C) {
	log.Init([]*log.LogConfig{&log.LogConfig{Name: "console"}})

	s.etcdNodes = os.Getenv("VULCAND_TEST_ETCD_NODES")
	if s.etcdNodes == "" {
		c.Skip("This test requires running Etcd, please provide url via VULCAND_TEST_ETCD_NODES environment variable")
		return
	}
	s.client = etcd.NewClient(strings.Split(s.etcdNodes, ","))

	s.etcdPrefix = os.Getenv("VULCAND_TEST_ETCD_PREFIX")
	if s.etcdPrefix == "" {
		c.Skip("This test requires Etcd prefix, please provide url via VULCAND_TEST_ETCD_PREFIX environment variable")
		return
	}

	s.apiUrl = os.Getenv("VULCAND_TEST_API_URL")
	if s.apiUrl == "" {
		c.Skip("This test requires running vulcand daemon, provide API url via VULCAND_TEST_API_URL environment variable")
		return
	}

	s.serviceUrl = os.Getenv("VULCAND_TEST_SERVICE_URL")
	if s.serviceUrl == "" {
		c.Skip("This test requires running vulcand daemon, provide API url via VULCAND_TEST_SERVICE_URL environment variable")
		return
	}
}
Beispiel #2
0
func main() {
	log.Init([]*log.LogConfig{&log.LogConfig{Name: "console"}})

	cmd := command.NewCommand(registry.GetRegistry())
	err := cmd.Run(os.Args)
	if err != nil {
		log.Errorf("Error: %s\n", err)
	}
}
Beispiel #3
0
func (s *Service) Start() error {
	log.Init([]*log.LogConfig{&log.LogConfig{Name: s.options.Log}})

	backend, err := etcdbackend.NewEtcdBackend(
		s.registry, s.options.EtcdNodes, s.options.EtcdKey, s.options.EtcdConsistency, &timetools.RealTime{})
	if err != nil {
		return err
	}
	s.backend = backend

	if s.options.PidPath != "" {
		if err := runtime.WritePid(s.options.PidPath); err != nil {
			return fmt.Errorf("failed to write PID file: %v\n", err)
		}
	}

	if err := s.createProxy(); err != nil {
		return err
	}

	go func() {
		s.errorC <- s.startProxy()
	}()

	s.configurator = configure.NewConfiguratorWithOptions(s.proxy, configure.Options{
		DialTimeout: s.options.EndpointDialTimeout,
		ReadTimeout: s.options.EndpointReadTimeout,
	})

	// Tell backend to watch configuration changes and pass them to the channel
	// the second parameter tells backend to do the initial read of the configuration
	// and produce the stream of changes so proxy would initialise initial config
	go s.watchChanges()

	if err := s.initApi(); err != nil {
		return err
	}

	go func() {
		s.errorC <- s.startApi()
	}()

	signal.Notify(s.sigC, os.Interrupt, os.Kill, syscall.SIGTERM)

	// Block until a signal is received or we got an error
	select {
	case signal := <-s.sigC:
		log.Infof("Got signal %s, exiting now", signal)
		return nil
	case err := <-s.errorC:
		log.Infof("Got request to shutdown with error: %s", err)
		return err
	}
	return nil
}
Beispiel #4
0
func (s *ApiSuite) SetUpSuite(c *C) {
	log.Init([]*log.LogConfig{&log.LogConfig{Name: "console"}})
}