From 005572308b7283fcfb0df7aebed03028ccb079de Mon Sep 17 00:00:00 2001 From: Xiaozhe Yao Date: Sun, 14 Oct 2018 17:48:53 +0800 Subject: [PATCH] [wip] solving #5 --- cli/daemon.go | 3 ++- cli/handler.go | 2 ++ cli/repository.go | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/daemon.go b/cli/daemon.go index 020353530..68193768a 100644 --- a/cli/daemon.go +++ b/cli/daemon.go @@ -14,12 +14,13 @@ type RunRepoRequest struct { Name string `json:name` Vendor string `json:vendor` Solver string `json:solver` + Port string `json:port` } func PostRepoHandler(c *gin.Context) { var runRepoRequest RunRepoRequest c.BindJSON(&runRepoRequest) - go runRepo(runRepoRequest.Vendor, runRepoRequest.Name, runRepoRequest.Solver) + go runRepo(runRepoRequest.Vendor, runRepoRequest.Name, runRepoRequest.Solver, runRepoRequest.Port) c.JSON(http.StatusOK, gin.H{ "code": "success", }) diff --git a/cli/handler.go b/cli/handler.go index 1954fba31..c14252338 100644 --- a/cli/handler.go +++ b/cli/handler.go @@ -86,12 +86,14 @@ func RepoHandler(c *cli.Context) { switch taskParams { case "run": solverstring := c.Args().Get(1) + runningPort := c.Args().Get(2) runParams := strings.Split(solverstring, "/") color.Cyan("Running " + runParams[0] + "/" + runParams[1] + "/" + runParams[2]) requestParams := map[string]string{ "vendor": runParams[0], "name": runParams[1], "solver": runParams[2], + "port": runningPort } ClientPost("repo", requestParams) case "ps": diff --git a/cli/repository.go b/cli/repository.go index 68f997445..2d9c07db7 100644 --- a/cli/repository.go +++ b/cli/repository.go @@ -62,7 +62,7 @@ func delRepo(repos []Repository, Vendor string, Name string) []Repository { return repos } -func runRepo(Vendor string, Name string, Solver string) { +func runRepo(Vendor string, Name string, Solver string, Port string) { repos := readRepos() existed := false for _, existed_repo := range repos { @@ -73,7 +73,7 @@ func runRepo(Vendor string, Name string, Solver string) { existed = true RunningRepos = append(RunningRepos, existed_repo) runfileFullPath := filepath.Join(existed_repo.LocalFolder, file.Name()) - python([]string{runfileFullPath}) + python([]string{runfileFullPath, Port}) } } }