puppet: Move generation of tornado nginx upstreams into tornado_sharding.

This puts the creation of the upstreams referenced by
`nginx_sharding.conf` adjacent to their use.
This commit is contained in:
Alex Vandiver 2020-09-09 11:56:17 -07:00 committed by Tim Abbott
parent bf029d99f1
commit 0de356c2df
4 changed files with 38 additions and 28 deletions

View File

@ -0,0 +1,17 @@
include /etc/nginx/zulip-include/tornado-upstreams;
upstream django {
server unix:/home/zulip/deployments/uwsgi-socket;
}
upstream localhost_sso {
server 127.0.0.1:8888;
}
upstream camo {
server 127.0.0.1:9292;
}
upstream thumbor {
server localhost:9995;
}

View File

@ -53,23 +53,12 @@ class zulip::app_frontend_base {
}
}
# The number of Tornado processes to run on the server; this
# defaults to 1, since Tornado sharding is currently only at the
# Realm level.
$tornado_processes = Integer(zulipconf('application_server', 'tornado_processes', 1))
if $tornado_processes > 1 {
$tornado_ports = range(9800, 9800 + $tornado_processes - 1)
$tornado_multiprocess = true
} else {
$tornado_multiprocess = false
}
file { '/etc/nginx/zulip-include/upstreams':
require => Package[$zulip::common::nginx],
owner => 'root',
group => 'root',
mode => '0644',
content => template('zulip/nginx/upstreams.conf.template.erb'),
source => 'puppet:///modules/zulip/nginx/zulip-include-frontend/upstreams',
notify => Service['nginx'],
}

View File

@ -25,4 +25,24 @@ class zulip::tornado_sharding {
content => "{}\n",
replace => false,
}
# The number of Tornado processes to run on the server; this
# defaults to 1, since Tornado sharding is currently only at the
# Realm level.
$tornado_processes = Integer(zulipconf('application_server', 'tornado_processes', 1))
if $tornado_processes > 1 {
$tornado_ports = range(9800, 9800 + $tornado_processes - 1)
$tornado_multiprocess = true
} else {
$tornado_multiprocess = false
}
file { '/etc/nginx/zulip-include/tornado-upstreams':
require => Package[$zulip::common::nginx],
owner => 'root',
group => 'root',
mode => '0644',
content => template('zulip/nginx/tornado-upstreams.conf.template.erb'),
notify => Service['nginx'],
}
}

View File

@ -1,7 +1,3 @@
upstream django {
server unix:/home/zulip/deployments/uwsgi-socket;
}
<% if @tornado_multiprocess -%>
<% @tornado_ports.each do |port| -%>
upstream tornado<%= port %> {
@ -15,15 +11,3 @@ upstream tornado {
keepalive 10000;
}
<% end -%>
upstream localhost_sso {
server 127.0.0.1:8888;
}
upstream camo {
server 127.0.0.1:9292;
}
upstream thumbor {
server localhost:9995;
}