diff --git a/crawler_manager.go b/crawler_manager.go index 50699cc..34d7b6b 100644 --- a/crawler_manager.go +++ b/crawler_manager.go @@ -16,6 +16,7 @@ import ( const ( address = "localhost:" + portArgsName = "-Port=" defaultPort = 50000 rootFolder = "/home/cm/" @@ -182,7 +183,7 @@ func (c *CrawlerManager)runContainer(container *string) error { cmdStr := getRunCommand(container) for { - pArg := "-Port=" + strconv.Itoa(c.currentPort) + pArg := portArgsName + strconv.Itoa(c.currentPort) cmd := exec.Command(cmdStr, pArg) err := cmd.Start() @@ -264,18 +265,6 @@ func (c *CrawlerManager)removeProcessFile(pid *string) { } } -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 -} - diff --git a/crawler_manager_test.go b/crawler_manager_test.go index 99bd6bf..07d3537 100644 --- a/crawler_manager_test.go +++ b/crawler_manager_test.go @@ -245,6 +245,6 @@ func TestRunRun(t *testing.T) { GetInstance().runContainer(&c) - //GetInstance().stopContainer(&c) + GetInstance().stopContainer(&c) } \ No newline at end of file diff --git a/crawler_util.go b/crawler_util.go index 1e07b50..e951d5c 100644 --- a/crawler_util.go +++ b/crawler_util.go @@ -1,6 +1,10 @@ package crawler_manager -import "io/ioutil" +import ( + "io/ioutil" + "strconv" + "os" +) func existConfigFile(prePath string,dir string) bool { @@ -41,3 +45,15 @@ 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 +} +