crawler_manager_go/crawler_util.go

60 lines
1.2 KiB
Go
Raw Normal View History

2017-04-15 11:10:33 +00:00
package crawler_manager
2017-04-15 11:27:40 +00:00
import (
"io/ioutil"
"strconv"
"os"
)
2017-04-15 11:10:33 +00:00
func existConfigFile(prePath string,dir string) bool {
files, _ := ioutil.ReadDir(prePath + "/" +dir)
for _,file := range files {
if file.IsDir() {
retB := existConfigFile(prePath + "/" + dir, file.Name())
if retB {
return true
}
} else {
return true
}
}
return false
}
func existConfigFileDir(prePath string,dir string, configCrawler *[]string) {
files, _ := ioutil.ReadDir(prePath + "/" +dir)
for _,file := range files {
if file.IsDir() {
existConfigFileDir(prePath + "/" + dir, file.Name(), configCrawler)
} else {
*configCrawler = append(*configCrawler, prePath + "/" +dir)
return;
}
}
}
func getRunCommand(container *string ) string {
2017-04-28 04:44:56 +00:00
return GetInstance().ConfigMgr.GetGlobalConfig().Paths.BinaryFolder + "/" + *container + "/" + GetInstance().ConfigMgr.GetGlobalConfig().Paths.ScriptFile
2017-04-15 11:10:33 +00:00
}
2017-04-15 11:27:40 +00:00
func writePid(pid int) {
2017-04-28 04:44:56 +00:00
ioutil.WriteFile(GetInstance().ConfigMgr.GetGlobalConfig().Paths.PidFolder + strconv.Itoa(pid), []byte(""), os.ModePerm)
2017-04-15 11:27:40 +00:00
}
func getConfigPaths(container *string) *[]string {
var dirs []string
2017-04-28 04:44:56 +00:00
existConfigFileDir(GetInstance().ConfigMgr.GetGlobalConfig().Paths.ConfigFolder, *container, &dirs)
2017-04-15 11:27:40 +00:00
return &dirs
}