Skip to content

Commit ed9ef71

Browse files
authored
Merge pull request #512 from cloudfoundry/disable-tcp-router
add a flag to turn off tcp_router
2 parents 93b7311 + 87c06e1 commit ed9ef71

20 files changed

+271
-16
lines changed

jobs/tcp_router/monit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
<% unless p("tcp_router.disable") %>
12
check process tcp_router
23
with pidfile /var/vcap/sys/run/bpm/tcp_router/tcp_router.pid
34
start program "/var/vcap/jobs/bpm/bin/bpm start tcp_router"
45
stop program "/var/vcap/jobs/bpm/bin/bpm stop tcp_router"
56
group vcap
7+
<% end %>

jobs/tcp_router/spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: tcp_router
33

44
templates:
55
tcp_router_ctl.erb: bin/tcp_router_ctl
6-
haproxy_reloader: bin/haproxy_reloader
6+
haproxy_reloader.erb: bin/haproxy_reloader
77
bpm-pre-start.erb: bin/bpm-pre-start
88
tcp_router.yml.erb: config/tcp_router.yml
99
uaa_ca.crt.erb: config/certs/uaa/ca.crt
@@ -39,6 +39,9 @@ consumes:
3939
optional: true
4040

4141
properties:
42+
tcp_router.disable:
43+
description: "Disable this monit job. It will not run."
44+
default: false
4245
tcp_router.debug_address:
4346
description: "Address at which to serve debug info"
4447
default: "127.0.0.1:17002"

jobs/tcp_router/templates/bpm-pre-start.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
<% unless p("tcp_router.disable") %>
23

34
set -eo pipefail
45

@@ -10,3 +11,4 @@ function copy_conf() {
1011
}
1112

1213
copy_conf
14+
<% end %>

jobs/tcp_router/templates/bpm.yml.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ bpm = {
2424
]
2525
}
2626

27-
YAML.dump(bpm)
27+
unless p("tcp_router.disable")
28+
YAML.dump(bpm)
29+
end
2830
%>

jobs/tcp_router/templates/drain.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# vim: set ft=sh
3-
43
set -e
4+
<% unless p("tcp_router.disable") %>
55

66
pidfile=/var/vcap/sys/run/bpm/tcp_router/tcp_router.pid
77
log_file=/var/vcap/sys/log/tcp_router/drain.log
@@ -33,3 +33,5 @@ else
3333
rm ${pidfile}
3434
echo 0
3535
fi
36+
37+
<% end %>

jobs/tcp_router/templates/haproxy.conf.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<% unless p("tcp_router.disable") %>
12
global
23
log 127.0.0.1 syslog info
34
daemon
@@ -28,3 +29,4 @@ listen health_check_https_url
2829
bind :<%= p("tcp_router.tls_health_check_port") %> ssl crt /var/vcap/jobs/tcp_router/config/certs/health.pem
2930
monitor-uri /health
3031
monitor fail if { env(IS_DRAINING) -m str true }
32+
<% end %>

jobs/tcp_router/templates/haproxy.conf.template.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<% unless p("tcp_router.disable") %>
12
global
23
log 127.0.0.1 syslog info
34
daemon
@@ -28,3 +29,4 @@ listen health_check_https_url
2829
bind :<%= p("tcp_router.tls_health_check_port") %> ssl crt /var/vcap/jobs/tcp_router/config/certs/health.pem
2930
monitor-uri /health
3031
monitor fail if { env(IS_DRAINING) -m str true }
32+
<% end %>

jobs/tcp_router/templates/haproxy_reloader renamed to jobs/tcp_router/templates/haproxy_reloader.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2+
<% unless p("tcp_router.disable") %>
23

34
set -e
4-
55
# ignore the SIGUSR2 signal in case we were reconfiguring haproxy while a SIGUSR2 event came in,
66
# we don't want to abort this process
77
trap "echo Ignoring SIGUSR2" SIGUSR2
@@ -44,3 +44,4 @@ trap cleanup EXIT INT TERM
4444
"${DAEMON}" -f "${CONFIG}" -p "${HAPROXY_PID_FILE}" -x "${HAPROXY_SOCKET_FILE}" -D -sf "$(cat ${HAPROXY_PID_FILE})" 0<&- &>> "${LOGFILE}"
4545

4646
echo "$(date --rfc-3339=ns) done" >> "${LOGFILE}"
47+
<% end %>

jobs/tcp_router/templates/post-start.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
2+
<% unless p("tcp_router.disable") %>
33
LOG_DIR=/var/vcap/sys/log/tcp_router
44
source /var/vcap/packages/routing_utils/syslog_utils.sh
55
<% lb_delay = p("tcp_router.load_balancer_healthy_threshold") %>
@@ -9,3 +9,4 @@ tee_output_to_sys_log "${LOG_DIR}" "post-start"
99
echo "Waiting <%= lb_delay %> seconds to allow load balancer to consider tcp_router healthy..."
1010
sleep <%= lb_delay %>
1111
echo "tcp_tcp_router is ready."
12+
<% end %>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash -e
2-
2+
<% unless p("tcp_router.disable") %>
33
# This pre-start script runs (1) config validation and (2) creates frontend certs on the VM (if any)
44
/var/vcap/packages/tcp_router/bin/config-validator -config /var/vcap/jobs/tcp_router/config/tcp_router.yml -enable-cert-creation true
5+
<% end %>
6+

0 commit comments

Comments
 (0)