-
Notifications
You must be signed in to change notification settings - Fork 27
/
nats.conf.erb
71 lines (57 loc) · 1.5 KB
/
nats.conf.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<%
def network_config
networks = spec.networks.marshal_dump
_, network = networks.find do |_name, network_spec|
network_spec.default
end
if !network
_, network = networks.first
end
if !network
raise "Could not determine IP via network spec: #{networks}"
end
network
end
def discover_external_ip
network_config.ip
end
def discover_external_hostname
network_config.dns_record_name
end
%>
<% self_host = discover_external_hostname %>
<% self_ip = discover_external_ip %>
<%
nats_ips = nil
if_p("nats.machines") { |ips| nats_ips = ips }
unless nats_ips
nats_ips = link("nats").instances.map(&:address)
end
%>
net: "<%= self_ip %>"
port: <%= p("nats.port") %>
prof_port: <%= p("nats.prof_port") %>
monitor_port: <%= p("nats.monitor_port") %>
pid_file: "/var/vcap/sys/run/nats/nats.pid"
debug: <%= p("nats.debug") %>
trace: <%= p("nats.trace") %>
logtime: true
authorization {
user: "<%= p("nats.user") %>"
password: "<%= p("nats.password") %>"
timeout: <%= p("nats.authorization_timeout") %>
}
cluster {
host: "<%= self_ip %>"
port: <%= p("nats.port") + 1 %>
authorization {
user: "<%= p("nats.user") %>"
password: "<%= p("nats.password") %>"
timeout: <%= p("nats.authorization_timeout") %>
}
routes = [
<% (nats_ips - [self_ip] - [self_host]).each do |address| %>
nats-route://<%= p("nats.user") %>:<%= p("nats.password") %>@<%= address %>:<%= p("nats.port") + 1 %>
<% end %>
]
}