--- /dev/null
+module OpenStreetMap
+ module Mixin
+ module CPU
+ def cpu_cores
+ [self.dig("cpu", "total").to_i, self.dig("cpu", "cores").to_i, 4].max
+ end
+ end
+ end
+end
+
+Chef::Node.include(OpenStreetMap::Mixin::CPU)
## How many concurrent web requests are supported? Depends on memory and CPU cores.
## will be set automatically by bootstrap based on detected CPUs, or you can override
- UNICORN_WORKERS: <%= [2, node.dig('cpu', 'total').to_i, node.dig('cpu', 'cores').to_i].max %>
+ UNICORN_WORKERS: <%= node.cpu_cores %>
## TODO: The domain name this Discourse instance will respond to
DISCOURSE_HOSTNAME: community.openstreetmap.org
bundle_install "/srv/#{year}.stateofthemap.org" do
action :nothing
- options "--deployment --jobs #{[4, node.dig('cpu', 'total').to_i, node.dig('cpu', 'cores').to_i].max}"
+ options "--deployment --jobs #{node.cpu_cores}"
user "root"
group "root"
notifies :run, "bundle_exec[/srv/#{year}.stateofthemap.org]"
--timestamp=${timestamp} \
--tile-dir=/srv/tile.openstreetmap.org/tiles \
--socket=/var/run/renderd/renderd.sock \
- --num-threads=<%= [4, node.dig('cpu', 'total').to_i - 1, node.dig('cpu', 'cores').to_i - 1].max %> \
+ --num-threads=<%= node.cpu_cores - 1 %> \
--map="<%= style %>" \
- --max-load=<%= [4, node.dig('cpu', 'total').to_i, node.dig('cpu', 'cores').to_i].max %> \
+ --max-load=<%= node.cpu_cores - 1 %> \
--min-zoom=0 --max-zoom=12
}
[renderd]
socketname=/var/run/renderd/renderd.sock
-num_threads=<%= [4, node.dig('cpu', 'total').to_i - 1, node.dig('cpu', 'cores').to_i - 1].max %>
+num_threads=<%= node.cpu_cores - 1 %>
tile_dir=/srv/tile.openstreetmap.org/tiles
stats_file=/var/run/renderd/renderd.stats
--timestamp=$(stat -c %Y "/srv/tile.openstreetmap.org/styles/<%= @style %>/project.xml") \
--tile-dir=/srv/tile.openstreetmap.org/tiles \
--socket=/var/run/renderd/renderd.sock \
- --num-threads=<%= [4, node.dig('cpu', 'total').to_i - 1, node.dig('cpu', 'cores').to_i - 1].max %> \
+ --num-threads=<%= node.cpu_cores - 1 %> \
--map="<%= @style %>" \
- --max-load=<%= [4, node.dig('cpu', 'total').to_i, node.dig('cpu', 'cores').to_i].max %> \
+ --max-load=<%= node.cpu_cores - 1 %> \
--min-zoom=0 --max-zoom=12
}