Exemplo n.º 1
0
// etcdNotes = strings.Split(os.Getenv("ETCD_NOTES"), ",")
func New(id string, etcdNodes []string, verbose bool) *Agent {
	localIp, err := GetLocalIPv4()
	if err != nil {
		panic(err)
	}

	return &Agent{
		ID:            id,
		IPv4:          localIp,
		state:         "_init",
		clusterClient: cluster.NewEtcdClient(etcdNodes),
		taskManager:   task.NewTaskManager(),
		jobScheduler:  scheduler.NewScheduler(),
		verbose:       verbose,
		jobSupervisor: new(supervisor.Supervisor),
	}
}
Exemplo n.º 2
0
// TODO(javier): Quick and dirty
func addJob(c *cli.Context) {
	//fmt.Println(spew.Sdump(c))
	var location string
	if len(c.Args()) == 0 {
		// lets assume you want to load batch files in the current dir
		location = "."
	} else {
		location = c.Args()[0] //TODO(javier): fix this
	}
	xchronoConfig := lookupXChronosConfig()
	jobConfig := parseJobs(location)
	//log.Println(spew.Sdump(jobConfig[0].Jobs[0]))
	fmt.Printf("Found %d batch files \n", len(jobConfig))

	proxy := cluster.NewEtcdClient(xchronoConfig.JobStore)
	fmt.Printf("==> Registering job: %s ...", jobConfig[0].Jobs[0].Name)
	proxy.RegisterJob(scheduler.NewJobFromConfig(jobConfig[0].Jobs[0]))
}
Exemplo n.º 3
0
// TODO(javier): Quick and dirty
func rmJob(c *cli.Context) {
	xchronosConfig := lookupXChronosConfig()
	proxy := cluster.NewEtcdClient(xchronosConfig.JobStore)
	proxy.UnregisterJobs()
}