Beispiel #1
0
func reload() {
	if len(os.Args) < 3 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	portstr := os.Args[2]
	port, err := strconv.Atoi(portstr)
	if err != nil {
		log.Error(err.Error())
		os.Exit(1)
	}
	hostprocess := &imgsvr.HostProcessor{
		Port:        port,
		ThreadCount: 0,
		NginxPath:   "",
		NginxPort:   "",
	}
	hostprocess.ReloadConf()
}
Beispiel #2
0
func h() {
	if len(os.Args) < 3 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	portstr := os.Args[2]
	port, err := strconv.Atoi(portstr)
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}
	threadcount, nginxpath, nginxport := getArgs()
	hostprocess := &imgsvr.HostProcessor{
		Port:        port,
		ThreadCount: threadcount,
		NginxPath:   nginxpath,
		NginxPort:   nginxport,
	}
	hostprocess.Run()
}
Beispiel #3
0
func (this *HostProcessor) sendCatHeartBeat() {
	defer func() {
		if err := recover(); err != nil {
			log.Error(fmt.Sprintf("%v", err))
			this.sendCatHeartBeat()
		}
	}()
	ip := GetIP()
	second := time.Now().Second()
	if second < 29 {
		sleep := time.Duration((29 - second) * 1000000000)
		time.Sleep(sleep)
	}

	catinstance := cat.Instance()
	for {
		log.Debug("send cat heartbeat")
		stats1 := GetStatus()
		data := url.Values{}
		data.Add("port", hostPort)
		for k, v := range stats1 {
			data.Add(k, v)
		}
		portstats[hostPort] = data

		tran := catinstance.NewTransaction("System", "Status")
		h := catinstance.NewHeartbeat("HeartBeat", ip)
		for _, heart := range portstats {
			if heart == nil {
				continue
			}
			port := heart.Get("port")
			if port == "" {
				continue
			}
			h.Set("System", JoinString("Alloc_", port), heart.Get("Alloc"))
			h.Set("System", JoinString("TotalAlloc_", port), heart.Get("TotalAlloc"))
			h.Set("System", JoinString("Sys_", port), heart.Get("Sys"))
			h.Set("System", JoinString("Mallocs_", port), heart.Get("Mallocs"))
			h.Set("System", JoinString("Frees_", port), heart.Get("Frees"))
			h.Set("System", JoinString("OtherSys_", port), heart.Get("OtherSys"))
			h.Set("System", JoinString("PauseNs_", port), heart.Get("PauseNs"))

			h.Set("HeapUsage", JoinString("HeapAlloc_", port), heart.Get("HeapAlloc"))
			h.Set("HeapUsage", JoinString("HeapSys_", port), heart.Get("HeapSys"))
			h.Set("HeapUsage", JoinString("HeapIdle_", port), heart.Get("HeapIdle"))
			h.Set("HeapUsage", JoinString("HeapInuse_", port), heart.Get("HeapInuse"))
			h.Set("HeapUsage", JoinString("HeapReleased_", port), heart.Get("HeapReleased"))
			h.Set("HeapUsage", JoinString("HeapObjects_", port), heart.Get("HeapObjects"))

			h.Set("GC", JoinString("NextGC_", port), heart.Get("NextGC"))
			h.Set("GC", JoinString("LastGC_", port), heart.Get("LastGC"))
			h.Set("GC", JoinString("NumGC_", port), heart.Get("NumGC"))
			portstats[port] = nil
		}
		h.SetStatus("0")
		h.Complete()
		tran.SetStatus("0")
		tran.Complete()
		second = time.Now().Second()
		sleep := time.Duration((90 - second) * 1000000000)
		time.Sleep(sleep)
	}
}