Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "metronome-scheduler", Short: "Metronome scheduler plan tasks executions", Long: `Metronome is a distributed and fault-tolerant event scheduler built with love by ovh teams and friends in Go. Complete documentation is available at http://ovh.github.io/metronome`, Run: func(cmd *cobra.Command, args []string) { log.Info("Metronome Scheduler starting") log.Info("Loading tasks") tc, err := routines.NewTaskConsumer() if err != nil { log.WithError(err).Fatal("Could not start the task consumer") } metrics.Serve() sigint := make(chan os.Signal, 1) signal.Notify(sigint, os.Interrupt) var schedulers sync.WaitGroup running := true loop: for { select { case partition := <-tc.Partitons(): schedulers.Add(1) go func() { log.Infof("Scheduler start %v", partition.Partition) ts, err := routines.NewTaskScheduler(partition.Partition, partition.Tasks) if err != nil { log.WithError(err).Error("Could not create a new task scheduler") return } tc.WaitForDrain() log.Infof("Scheduler tasks loaded %v", partition.Partition) if running { if err = ts.Start(); err != nil { log.WithError(err).Error("Could not start the task scheduler") return } log.Infof("Scheduler started %v", partition.Partition) } ts.Halted() log.Infof("Scheduler halted %v", partition.Partition) schedulers.Done() }() case <-sigint: log.Info("Shuting down") running = false break loop } } if err = tc.Close(); err != nil { log.WithError(err).Error("Could not stop gracefully the task consumer") } log.Infof("Consumer halted") schedulers.Wait() }, }
RootCmd launch the scheduler agent.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.