Skip to content

Commit

Permalink
Add special BAMBOO_TCP_PORT variable logic to add tcp mode service
Browse files Browse the repository at this point in the history
Defining BAMBOO_TCP_PORT in the Marathon task definition, e.g.

	{
	  "id": "test",
	  "cmd": "python -m SimpleHTTPServer $PORT0",
	  "cpus": 0.1,
	  "mem": 90,
	  "ports": [0],
	  "instances": 1
	  "env": {
	    "BAMBOO_TCP_PORT": "1080"
	  }
	}

leads to

	listen ::test-cluster-tcp :1081
	        mode tcp
	        option tcplog
	        balance roundrobin

        	server ::test-192.168.2.2-31001 192.168.2.2:31001

in the haproxy configuration.

Fixes QubitProducts#28.
  • Loading branch information
sttts committed Jan 5, 2015
1 parent f4c063f commit 591e06d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions config/haproxy_template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ defaults
timeout client 50000
timeout server 50000

stats enable
# CHANGE: Your stats credentials
stats auth admin:admin
stats uri /haproxy_stats

errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
Expand All @@ -53,9 +48,20 @@ frontend http-in
use_backend {{ $app.EscapedId }}-cluster if {{ $app.EscapedId }}-aclrule
{{ end }} {{ end }}

{{ range $index, $app := .Apps }}
backend {{ $app.EscapedId }}-cluster
{{ if $app.HealthCheckPath }}
stats enable
# CHANGE: Your stats credentials
stats auth admin:admin
stats uri /haproxy_stats

{{ range $index, $app := .Apps }} {{ if $app.Env.BAMBOO_TCP_PORT }}
listen {{ $app.EscapedId }}-cluster-tcp :{{ $app.Env.BAMBOO_TCP_PORT }}
mode tcp
option tcplog
balance roundrobin
{{ range $page, $task := .Tasks }}
server {{ $app.EscapedId}}-{{ $task.Host }}-{{ $task.Port }} {{ $task.Host }}:{{ $task.Port }} {{ if $app.HealthCheckPath }} check inter 30000 {{ end }} {{ end }}
{{ end }}
backend {{ $app.EscapedId }}-cluster{{ if $app.HealthCheckPath }}
option httpchk GET {{ $app.HealthCheckPath }}
{{ end }}
balance leastconn
Expand Down

0 comments on commit 591e06d

Please sign in to comment.