Skip to content

Commit

Permalink
Merge pull request #2 from MiLk/multiple-ports
Browse files Browse the repository at this point in the history
Merge from MiLk/bamboo:multiple-ports from multiple ports of Marathon apps. I will test it, and ensure it's testted.
  • Loading branch information
Robert Hao committed Apr 15, 2015
2 parents cea42f2 + df7ae01 commit 931bca1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions config/haproxy_template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ backend {{ $app.EscapedId }}-cluster{{ if $app.HealthCheckPath }}
## to haproxy frontend port
##
## {{ range $index, $app := .Apps }}
## listen {{ $app.EscapedId }}_{{ $app.ServicePort }}
## bind *:{{ $app.ServicePort }}
## {{ range $serviceIndex, $servicePort := $app.ServicePorts }}
## listen {{ $app.EscapedId }}_{{ $servicePort }}
## bind *:{{ $servicePort }}
## mode http
## {{ if $app.HealthCheckPath }}
## # option httpchk GET {{ $app.HealthCheckPath }}
## {{ end }}
## balance leastconn
## option forwardfor
## {{ range $page, $task := .Tasks }}
## server {{ $app.EscapedId}}-{{ $task.Host }}-{{ $task.Port }} {{ $task.Host }}:{{ $task.Port }} {{ if $app.HealthCheckPath }} check inter 30000 {{ end }} {{ end }}
## {{ range $page, $task := $app.Tasks }}
## server {{ $app.EscapedId }}-{{ $task.Host }}-{{ index $task.Ports $serviceIndex }} {{ $task.Host }}:{{ index $task.Ports $serviceIndex }} {{ if $app.HealthCheckPath }} check inter 30000 {{ end }} {{ end }}
## {{ end }}
## {{ end }}
9 changes: 6 additions & 3 deletions services/marathon/marathon.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (

// Describes an app process running
type Task struct {
Host string
Port int
Host string
Port int
Ports []int
}

// An app may have multiple processes
Expand All @@ -22,6 +23,7 @@ type App struct {
HealthCheckPath string
Tasks []Task
ServicePort int
ServicePorts []int
Env map[string]string
}

Expand Down Expand Up @@ -158,7 +160,7 @@ func createApps(tasksById map[string][]MarathonTask, marathonApps map[string]Mar

for _, task := range tasks {
if len(task.Ports) > 0 {
simpleTasks = append(simpleTasks, Task{Host: task.Host, Port: task.Ports[0]})
simpleTasks = append(simpleTasks, Task{Host: task.Host, Port: task.Ports[0], Ports: task.Ports})
}
}

Expand All @@ -180,6 +182,7 @@ func createApps(tasksById map[string][]MarathonTask, marathonApps map[string]Mar

if len(marathonApps[appId].Ports) > 0 {
app.ServicePort = marathonApps[appId].Ports[0]
app.ServicePorts = marathonApps[appId].Ports
}

apps = append(apps, app)
Expand Down

0 comments on commit 931bca1

Please sign in to comment.