mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
puppet: Make memory computations work with Puppet 4.
The actual approach for achieving this goal is to take our manual parsing and move it to the central base.pp.
This commit is contained in:
@@ -56,7 +56,7 @@ class zulip::app_frontend_base {
|
||||
# This determines whether we run queue processors multithreaded or
|
||||
# multiprocess. Multiprocess scales much better, but requires more
|
||||
# RAM; we just auto-detect based on available system RAM.
|
||||
$queues_multiprocess = $::memorysize_mb > 3500
|
||||
$queues_multiprocess = $zulip::base::total_memory_mb > 3500
|
||||
$queues = $zulip::base::normal_queues
|
||||
if $queues_multiprocess {
|
||||
$message_sender_default_processes = 4
|
||||
|
||||
@@ -73,6 +73,11 @@ class zulip::base {
|
||||
'user_presence',
|
||||
]
|
||||
|
||||
# We can't use the built-in $memorysize fact because it's a string with human-readable units
|
||||
# Meanwhile $memorysize_mb is a string, and can't be compared with integers in puppet 4.
|
||||
$total_memory = regsubst(file('/proc/meminfo'), '^.*MemTotal:\s*(\d+) kB.*$', '\1', 'M') * 1024
|
||||
$total_memory_mb = $total_memory / 1024 / 1024
|
||||
|
||||
group { 'zulip':
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ if $zulip::base::release_name == 'trusty' {
|
||||
content => template("zulip/postgresql/${zulip::base::postgres_version}/postgresql.conf.template.erb"),
|
||||
}
|
||||
|
||||
# We can't use the built-in $memorysize fact because it's a string with human-readable units
|
||||
$total_memory = regsubst(file('/proc/meminfo'), '^.*MemTotal:\s*(\d+) kB.*$', '\1', 'M') * 1024
|
||||
$half_memory = $total_memory / 2
|
||||
$half_memory = $zulip::base::total_memory / 2
|
||||
$half_memory_pages = $half_memory / 4096
|
||||
|
||||
file {'/etc/sysctl.d/40-postgresql.conf':
|
||||
@@ -57,16 +55,13 @@ vm.dirty_background_ratio = 5
|
||||
subscribe => [ Exec['pgtune'], File['/etc/sysctl.d/40-postgresql.conf'] ]
|
||||
}
|
||||
} else {
|
||||
# We can't use the built-in $memorysize fact because it's a string with human-readable units
|
||||
$total_memory = regsubst(file('/proc/meminfo'), '^.*MemTotal:\s*(\d+) kB.*$', '\1', 'M') * 1024
|
||||
$half_memory = $total_memory / 2
|
||||
$half_memory = $zulip::base::total_memory / 2
|
||||
$half_memory_pages = $half_memory / 4096
|
||||
$total_memory_mb = $total_memory / 1024 / 1024
|
||||
|
||||
$work_mem = $total_memory_mb / 512
|
||||
$shared_buffers = $total_memory_mb / 8
|
||||
$effective_cache_size = $total_memory_mb * 10 / 32
|
||||
$maintenance_work_mem = $total_memory_mb / 32
|
||||
$work_mem = $zulip::base::total_memory_mb / 512
|
||||
$shared_buffers = $zulip::base::total_memory_mb / 8
|
||||
$effective_cache_size = $zulip::base::total_memory_mb * 10 / 32
|
||||
$maintenance_work_mem = $zulip::base::total_memory_mb / 32
|
||||
|
||||
$random_page_cost = zulipconf('postgresql', 'random_page_cost', undef)
|
||||
$effective_io_concurrency = zulipconf('postgresql', 'effective_io_concurrency', undef)
|
||||
|
||||
Reference in New Issue
Block a user