Ejemplo n.º 1
0
func (r *runner) run() {
	ctx, cancel := context.WithCancel(context.Background())
STOP:
	for {
		select {
		case <-r.done:
			cancel()
			break STOP
		case serv := <-r.add:
			go func(c context.Context, s core.Service) {
				serviceUUID := util.GenUUID()

				ctxWith, servCancel := context.WithCancel(ctx)

				err := s.Init(ctxWith, serviceUUID)
				if err != nil {
					//TODO handle?
				}
				info := s.Info()
				serviceName := info.Name() + "." + fmt.Sprint(info.Status()) + "." + info.ID()
				go r.monitorService(ctxWith, servCancel, s)
				r.running.add(s.Info())
				registry.Register(serviceName, s)
			}(ctx, serv)
		}
	}
}
Ejemplo n.º 2
0
func Boot() {

	// Rgister all core services
	registry.Register(coreServices.Config, &config.Service{})
	registry.Register(coreServices.Store, &store.DB{})
	registry.Register(coreServices.Mdown, &mdown.Markdown{})
	registry.Register(coreServices.View, &view.Renderer{})

	// Make sure at least one instance of config is running
	// before anything else.
	orchestra.Start(coreServices.Config)
	orchestra.Start(coreServices.Mdown)
	orchestra.Start(coreServices.Store)
	orchestra.Start(coreServices.View)

}