Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/running port#5 #59

Merged
merged 2 commits into from
Oct 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 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,13 +73,13 @@ 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})
}
}
}
}
if !existed {
log.Fatal("Solver Not Found!")
log.Fatal("Solver Not Found! Expecting " + Solver)
}
}

Expand Down