Esempio n. 1
0
func main() {
	dal, err := release.NewDal()
	if err != nil {
		log.Printf("New DAL failed: %s\n", err)
		panic(err)
	}
	defer dal.Close()

	counter := 0
	for {
		counter = counter + 1
		log.Printf("scan %d times ----------------------------begin\n", counter)
		for _, path := range dir_list {
			if exist, err := pathutil.IsExist(path); !exist && err == nil {
				//			pathutil.MkDir(path)
				log.Printf("scan dir error : %s\n", err)
				continue
			}

			mode := constant.PATH_TO_MODE[path]
			sim := constant.MODE_TO_SIM[mode]

			err := ScanDir(dal, path, mode, sim)
			if err != nil {
				log.Printf("Scan PANIC [%s] failed : %s\n", path, err)
				panic(err)
			}
		}
		log.Printf("scan %d times ----------------------------end\n", counter)
		time.Sleep(SCAN_INTERNAL * time.Second)
	}
}
Esempio n. 2
0
func CheckConsistency(dal *release.Dal, mode string) error {
	query := fmt.Sprintf("SELECT * FROM %s where mode='%s' and flag=%d", constant.TABLE_CP, mode, constant.AVAILABLE_FLAG)
	cp_list, err := release.FindCpReleaseList(dal, query)
	if err != nil {
		return err
	}

	for _, cp := range cp_list {
		full_path := fmt.Sprintf("%s%s", constant.CP_RELEASE_ROOT_FINAL, cp.RelPath)
		exist, err := pathutil.IsExist(full_path)
		if err != nil {
			continue
		}

		if !exist {
			log.Printf("CheckDir db and fs unmatched, delete db record: %s", cp)
			cp.Delete(dal)
			release.DeleteArbiByCpId(dal, cp.Id)
			release.DeleteGrbiByCpId(dal, cp.Id)
			release.DeleteRficByCpId(dal, cp.Id)
		} else {
			ProcessDetail(cp, dal)
		}
	}
	return nil
}
Esempio n. 3
0
func main() {
	done := make(chan bool)
	for _, path := range dir_list {
		if exist, err := pathutil.IsExist(path); !exist && err == nil {
			//			pathutil.MkDir(path)
			continue
		}

		err := MonitorDir(path)
		if err != nil {
			log.Printf("Monitor [%s] failed : %s\n", path, err)
			panic(err)
		}
	}
	<-done
}