예제 #1
0
func Run() {
	cfg.Load()
	sheepCfgLs := cfg.LoadConfigFile()
	log4go.New(cfg.LOGPATH)
	log4go.Logger.Printf("[SYSTEM]START SYSTEM INIT.")
	maxProcs := runtime.NumCPU()
	log4go.Logger.Printf("[SYSTEM]CPU NUM: %d ", maxProcs)
	runtime.GOMAXPROCS(maxProcs)
	log4go.Logger.Printf("[SYSTEM]MAX GOROUTINE: %d ", maxProcs)
	SignalHandle.StartSignalHandle("interrupt", exit.Now, true)
	log4go.Logger.Printf("[SYSTEM]FINISH SYSTEM INIT.")
	//add sheep
	log4go.Logger.Printf("[INFO]Start Loading sheeps .")
	for _, sheepCfg := range sheepCfgLs {
		sheep.SHEEPS[sheepCfg.NAME] = sheep.New(sheepCfg)
	}
	log4go.Logger.Printf("[INFO]Load sheeps success .")
	//
	log4go.Logger.Printf("[INFO]Start Yell .")
	exit.ALL.Add(1)
	go yell.Start()
	exit.ALL.Add(1)
	go http.Start()
	exit.ALL.Wait()
}
예제 #2
0
파일: a.go 프로젝트: luckykris/shepherd
func main() {
	runtime.GOMAXPROCS(4)
	var err error
	var i int = 1
	a, _ := diskq.New("dalian_jdq", "/tmp/", 50, 1024)
	SignalHandle.StartSignalHandle("interrupt", func() {
		a.Close()
		fmt.Println("i am exiting")
	}, true)

	a.PersistLastFail("test")
	tmp, _ := a.GetLastFail()
	fmt.Println(tmp)
	a.PersistLastFail(nil)
	tmp, _ = a.GetLastFail()
	fmt.Println(tmp)

	err = a.LoadQueue()
	if err != nil {
		fmt.Println(err.Error())
	} else {
		qls, err := a.SnapShot()
		fmt.Println(qls)
		if err != nil {
			fmt.Println(err.Error())
		} else {
			for i = 0; i < len(qls); i++ {
				fmt.Println(string(qls[i]))
			}
		}
		c, err := a.Get(false)
		if err != nil {
			fmt.Println(err.Error())
			i = 1
		} else {
			tmp, _ := strconv.Atoi(string(c))
			fmt.Printf("Get:%s,length:%d\n", string(c), a.Length())
			i = tmp + int(a.Length()) + 1
		}
	}
	go ppu(a, i)
	go ppu(a, i)
	go ppu(a, i)
	go ppu(a, i)
	go ppu(a, i)
	go ppu(a, i)
	for {
		//time.Sleep(1 * time.Second)
		c, err := a.Get(true)
		if err != nil {
			fmt.Println(err.Error())
			fmt.Println("break")
			return
		}
		fmt.Printf("Get:%s,length:%d\n", string(c), a.Length())
	}
}
예제 #3
0
func Run() {
	dog_cfg.Load()
	log4go.New(*dog_cfg.LOGPATH)
	log4go.Logger.Printf("[SYSTEM]START SYSTEM INIT.")
	maxProcs := runtime.NumCPU()
	log4go.Logger.Printf("[SYSTEM]CPU NUM: %d ", maxProcs)
	runtime.GOMAXPROCS(maxProcs)
	log4go.Logger.Printf("[SYSTEM]MAX GOROUTINE: %d ", maxProcs)
	SignalHandle.StartSignalHandle("interrupt", exit.Now, true)
	log4go.Logger.Printf("[SYSTEM]FINISH SYSTEM INIT.")
	URL := fmt.Sprintf("%s:%d", *dog_cfg.HOST, *dog_cfg.PORT)
	go protocol.StartShepherdDog(URL, *dog_cfg.SCRIPT)
	<-exit.SAFE
}