Ejemplo n.º 1
0
func main() {
	var bootId string

	f := flag.NewFlagSet(os.Args[0], 1)
	f.StringVar(&bootId, "bootid", "", "Provide a user-generated boot ID. This will override the actual boot ID of the machine.")
	f.Parse(os.Args[1:])

	if bootId == "" {
		bootId = machine.ReadLocalBootId()
	}

	m := machine.New(bootId)
	r := registry.New()
	a := agent.New(r, m, "")

	// Push the initial state to the registry
	a.UpdateJobs()
	a.UpdateMachine()

	// Kick off the heartbeating process
	go a.DoHeartbeat()

	s := scheduler.New(r, m)
	s.DoSchedule()
}
Ejemplo n.º 2
0
func (self *Server) Configure(cfg *config.Config) {
	if cfg.BootId != self.machine.BootId {
		self.machine = machine.New(cfg.BootId)
		self.agent.Stop()
		self.agent = agent.New(self.registry, self.events, self.machine, "")
		go self.agent.Run()
	}
}
Ejemplo n.º 3
0
func (self *Server) Configure(cfg *config.Config) {
	if cfg.BootId != self.machine.BootId {
		self.machine = machine.New(cfg.BootId, cfg.PublicIP, cfg.Metadata())
		self.agent.Stop()
		self.agent = agent.New(self.registry, self.events, self.machine, "", cfg.UnitPrefix)
		go self.agent.Run()
	}
}
Ejemplo n.º 4
0
func New(cfg config.Config) *Server {
	m := machine.New(cfg.BootId)
	r := registry.New()
	es := registry.NewEventStream()

	a := agent.New(r, es, m, "")
	e := engine.New(r, es, m)

	srv := Server{a, e, m, r, es}
	srv.Configure(&cfg)

	return &srv
}
Ejemplo n.º 5
0
func New(cfg config.Config) *Server {
	m := machine.New(cfg.BootId, cfg.PublicIP, cfg.Metadata())

	regClient := etcd.NewClient(cfg.EtcdServers)
	regClient.SetConsistency(etcd.WEAK_CONSISTENCY)
	r := registry.New(regClient)

	eventClient := etcd.NewClient(cfg.EtcdServers)
	eventClient.SetConsistency(etcd.WEAK_CONSISTENCY)
	es := registry.NewEventStream(eventClient, r)
	es.Open()

	a := agent.New(r, es, m, "", cfg.UnitPrefix)
	e := engine.New(r, es, m)

	return &Server{a, e, m, r, es}
}