Skip to content

Commit

Permalink
Merge pull request #934 from pwzgorilla/master
Browse files Browse the repository at this point in the history
add task failover for new compose api
  • Loading branch information
gorilla authored Sep 22, 2017
2 parents a693c02 + f1b615d commit 9058451
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
26 changes: 18 additions & 8 deletions api/compose-ng.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ func (r *Server) runComposeNG(w http.ResponseWriter, req *http.Request) {
return
}

var (
restart = ver.RestartPolicy
retries = 3
)

if restart != nil && restart.Retries >= 0 {
retries = restart.Retries
}

for i := 0; i < count; i++ {
var (
taskName = fmt.Sprintf("%d.%s", i, appId)
Expand All @@ -194,14 +203,15 @@ func (r *Server) runComposeNG(w http.ResponseWriter, req *http.Request) {

// db task
task := &types.Task{
ID: taskId,
Name: taskName,
Weight: 100,
Status: "pending",
Healthy: types.TaskHealthyUnset,
Version: ver.ID,
Created: time.Now(),
Updated: time.Now(),
ID: taskId,
Name: taskName,
Weight: 100,
Status: "pending",
Healthy: types.TaskHealthyUnset,
Version: ver.ID,
MaxRetries: retries,
Created: time.Now(),
Updated: time.Now(),
}

if ver.IsHealthSet() {
Expand Down
2 changes: 1 addition & 1 deletion mole/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (m *Master) handle(conn net.Conn) {
switch cmd.Cmd {

case cmdJoin:
log.Println("agent joined", cmd.AgentID)
log.Println("agent joined with ID", cmd.AgentID)
m.AddAgent(cmd.AgentID, conn) // this is the persistent control connection

case cmdNewWorker:
Expand Down

0 comments on commit 9058451

Please sign in to comment.