Skip to content

Commit

Permalink
[wip] solving #5
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Oct 14, 2018
1 parent e68bf29 commit 0055723
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cli/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
Expand Down
2 changes: 2 additions & 0 deletions cli/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions cli/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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})
}
}
}
Expand Down

0 comments on commit 0055723

Please sign in to comment.