Beispiel #1
0
func (c *AppCollectorService) StopInterval(r *http.Request, args *AppCollectorArgs, reply *AppCollectorReply) error {
	log.Println("rpc invoke StopInterval")
	m := monitor.NewAppCollector()
	id, err := strconv.Atoi(args.AppId)
	app := &models.MonitorApp{Id: id}
	reply.Message = "stop success"
	if err != nil {
		reply.Message = err.Error()
		return err
	}
	m.StopInterval(app)
	return nil
}
func main() {
	workers.Configure(map[string]string{
		// location of redis instance
		"server": "localhost:6379",
		// instance of the database
		"database": "0",
		// number of connections to keep open with redis
		"pool": "30",
		// unique process id for this instance of workers (for proper recovery of inprogress jobs on crash)
		"process": "1",
	})
	//start collector
	monitor.NewAppCollector().Run()
	workers.Middleware.Append(&myMiddleware{})
	workers.Process("checklist", myJob, 20)
	// stats will be available at http://localhost:8080/stats
	go workers.StatsServer(8081)
	// Blocks until process is told to exit via unix signal
	rpc.Run()
	workers.Run()
}
Beispiel #3
0
func (c *AppCollectorService) StartInterval(r *http.Request, args *AppCollectorArgs, reply *AppCollectorReply) error {
	log.Println("rpc invoke StartInterval" + args.Name)
	m := monitor.NewAppCollector()
	id, err := strconv.Atoi(args.AppId)
	checkInterval, errci := strconv.Atoi(args.CheckInterval)
	retryTime, _ := strconv.Atoi(args.CheckInterval)
	status, _ := strconv.Atoi(args.Status)
	app := &models.MonitorApp{Id: id, CheckInterval: checkInterval,
		Name: args.Name, Url: args.Url,
		RetryTime: retryTime,
		Status:    status}
	reply.Message = "start success"
	if err != nil {
		reply.Message = err.Error()
		return err
	}
	if errci != nil {
		reply.Message = err.Error()
		return errci
	}
	m.GmStartInterval(app)
	return nil

}