60 lines
1.0 KiB
Go
60 lines
1.0 KiB
Go
package crawler_manager
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"strconv"
|
|
"os"
|
|
)
|
|
|
|
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 {
|
|
return BinaryFolder + "/" + *container + "/" + runFile
|
|
}
|
|
|
|
func writePid(pid int) {
|
|
ioutil.WriteFile(PidFolder + strconv.Itoa(pid), []byte(""), os.ModePerm)
|
|
}
|
|
|
|
func getConfigPaths(container *string) *[]string {
|
|
|
|
var dirs []string
|
|
existConfigFileDir(ConfigFolder, *container, &dirs)
|
|
|
|
return &dirs
|
|
}
|
|
|