From: Tom Hughes Date: Mon, 10 Feb 2014 18:42:18 +0000 (+0000) Subject: Move passenger configuration to a separate cookbook X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/da1115e80fdbca939aa7b2f8b2027705f1c32b24 Move passenger configuration to a separate cookbook --- diff --git a/cookbooks/dev/metadata.rb b/cookbooks/dev/metadata.rb index 4279f393b..6362520c6 100644 --- a/cookbooks/dev/metadata.rb +++ b/cookbooks/dev/metadata.rb @@ -6,6 +6,7 @@ description "Installs and configures dev services" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" depends "apache" +depends "passenger" depends "git" depends "mysql" depends "postgresql" diff --git a/cookbooks/dev/recipes/default.rb b/cookbooks/dev/recipes/default.rb index f8098faec..646b170e2 100644 --- a/cookbooks/dev/recipes/default.rb +++ b/cookbooks/dev/recipes/default.rb @@ -20,6 +20,7 @@ require "yaml" include_recipe "apache" +include_recipe "passenger" include_recipe "git" include_recipe "mysql" include_recipe "postgresql" @@ -53,15 +54,6 @@ apache_module "rewrite" apache_module "expires" apache_module "wsgi" -apache_module "passenger" do - conf "passenger.conf.erb" -end - -munin_plugin "passenger_memory" -munin_plugin "passenger_processes" -munin_plugin "passenger_queues" -munin_plugin "passenger_requests" - gem_package "sqlite3" gem_package "rails" do @@ -152,7 +144,7 @@ if node[:postgresql][:clusters][:"9.1/main"] end rails_port site_name do - ruby node[:dev][:ruby] + ruby node[:passenger][:ruby_version] directory rails_directory user "apis" group "apis" diff --git a/cookbooks/dev/templates/default/passenger.conf.erb b/cookbooks/dev/templates/default/passenger.conf.erb deleted file mode 100644 index 42639f105..000000000 --- a/cookbooks/dev/templates/default/passenger.conf.erb +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef - - - PassengerRoot /usr - PassengerRuby /usr/bin/ruby<%= node[:dev][:ruby] %> - PassengerUseGlobalQueue on - diff --git a/cookbooks/passenger/README.md b/cookbooks/passenger/README.md new file mode 100644 index 000000000..205739199 --- /dev/null +++ b/cookbooks/passenger/README.md @@ -0,0 +1,34 @@ +Cookbook +======== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +Attributes +---------- +TODO: List you cookbook attributes here. + +Usage +----- +TODO: Write usage instructions for each cookbook. + +Contributing +------------ +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +License and Authors +------------------- +Authors: TODO: List authors diff --git a/cookbooks/passenger/attributes/default.rb b/cookbooks/passenger/attributes/default.rb new file mode 100644 index 000000000..0c1c8ece5 --- /dev/null +++ b/cookbooks/passenger/attributes/default.rb @@ -0,0 +1,5 @@ +default[:apt][:sources] = node[:apt][:sources] | [ "brightbox-ruby-ng" ] + +default[:passenger][:ruby_version] = "1.9.1" +default[:passenger][:max_pool_size] = 6 +default[:passenger][:pool_idle_time] = 300 diff --git a/cookbooks/passenger/metadata.rb b/cookbooks/passenger/metadata.rb new file mode 100644 index 000000000..bad97ca8b --- /dev/null +++ b/cookbooks/passenger/metadata.rb @@ -0,0 +1,9 @@ +name "passenger" +maintainer "OpenStreetMap Administrators" +maintainer_email "admins@openstreetmap.org" +license "Apache 2.0" +description "Installs and configures passenger" +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version "1.0.0" +depends "apache" +depends "munin" diff --git a/cookbooks/passenger/recipes/default.rb b/cookbooks/passenger/recipes/default.rb new file mode 100644 index 000000000..6656ce338 --- /dev/null +++ b/cookbooks/passenger/recipes/default.rb @@ -0,0 +1,39 @@ +# +# Cookbook Name:: passenger +# Recipe:: default +# +# Copyright 2014, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "apache" + +template "/usr/local/bin/passenger-ruby" do + source "ruby.erb" + owner "root" + group "root" + mode 0755 + notifies :reload, "service[apache2]" +end + +apache_module "passenger" do + conf "passenger.conf.erb" +end + +package "passenger-common#{node[:passenger][:ruby_version]}" + +munin_plugin "passenger_memory" +munin_plugin "passenger_processes" +munin_plugin "passenger_queues" +munin_plugin "passenger_requests" diff --git a/cookbooks/passenger/templates/default/passenger.conf.erb b/cookbooks/passenger/templates/default/passenger.conf.erb new file mode 100644 index 000000000..a234b15a2 --- /dev/null +++ b/cookbooks/passenger/templates/default/passenger.conf.erb @@ -0,0 +1,9 @@ +# DO NOT EDIT - This file is being maintained by Chef + + + PassengerRoot /usr + PassengerRuby /usr/local/bin/passenger-ruby + PassengerUseGlobalQueue on + PassengerMaxPoolSize <%= node[:passenger][:max_pool_size] %> + PassengerPoolIdleTime <%= node[:passenger][:pool_idle_time] %> + diff --git a/cookbooks/web/templates/default/ruby.erb b/cookbooks/passenger/templates/default/ruby.erb similarity index 65% rename from cookbooks/web/templates/default/ruby.erb rename to cookbooks/passenger/templates/default/ruby.erb index a7c742112..4d962204e 100644 --- a/cookbooks/web/templates/default/ruby.erb +++ b/cookbooks/passenger/templates/default/ruby.erb @@ -4,4 +4,4 @@ export RUBY_HEAP_MIN_SLOTS=500000 export RUBY_HEAP_FREE_MIN=100000 export RUBY_GC_MALLOC_LIMIT=50000000 -exec /usr/bin/ruby<%= node[:web][:ruby_version] %> "$@" +exec /usr/bin/ruby<%= node[:passenger][:ruby_version] %> "$@" diff --git a/cookbooks/taginfo/metadata.rb b/cookbooks/taginfo/metadata.rb index 795a69aa0..2ba1d35be 100644 --- a/cookbooks/taginfo/metadata.rb +++ b/cookbooks/taginfo/metadata.rb @@ -6,6 +6,7 @@ description "Installs and configures taginfo" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" depends "apache" +depends "passenger" depends "git" attribute "taginfo", diff --git a/cookbooks/taginfo/recipes/default.rb b/cookbooks/taginfo/recipes/default.rb index bdac49455..b4f487a05 100644 --- a/cookbooks/taginfo/recipes/default.rb +++ b/cookbooks/taginfo/recipes/default.rb @@ -18,6 +18,7 @@ # include_recipe "apache::ssl" +include_recipe "passenger" include_recipe "git" package "libsqlite3-dev" @@ -41,13 +42,6 @@ gem_package "sinatra" gem_package "sinatra-r18n" gem_package "rack-contrib" -apache_module "passenger" - -munin_plugin "passenger_memory" -munin_plugin "passenger_processes" -munin_plugin "passenger_queues" -munin_plugin "passenger_requests" - node[:taginfo][:sites].each do |site| name = site[:name] directory = site[:directory] || "/srv/#{name}" diff --git a/cookbooks/web/attributes/default.rb b/cookbooks/web/attributes/default.rb index 54d692f31..8ad59e544 100644 --- a/cookbooks/web/attributes/default.rb +++ b/cookbooks/web/attributes/default.rb @@ -1,4 +1,3 @@ -default[:web][:ruby_version] = "1.9.1" default[:web][:base_directory] = "/srv/www.openstreetmap.org" default[:web][:pid_directory] = "/var/run/web" default[:web][:log_directory] = "/var/log/web" diff --git a/cookbooks/web/metadata.rb b/cookbooks/web/metadata.rb index 468aea910..1ef28bbbb 100644 --- a/cookbooks/web/metadata.rb +++ b/cookbooks/web/metadata.rb @@ -6,6 +6,7 @@ description "Installs and configures www.openstreetmap.org servers" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" depends "apache" +depends "passenger" depends "git" depends "memcached" depends "tools" diff --git a/cookbooks/web/recipes/rails.rb b/cookbooks/web/recipes/rails.rb index ca27a5081..1a8ef4122 100644 --- a/cookbooks/web/recipes/rails.rb +++ b/cookbooks/web/recipes/rails.rb @@ -21,36 +21,12 @@ include_recipe "tools" include_recipe "web::base" include_recipe "apache" +include_recipe "passenger" include_recipe "git" web_passwords = data_bag_item("web", "passwords") db_passwords = data_bag_item("db", "passwords") -directory "#{node[:web][:base_directory]}/bin" do - owner "root" - group "root" - mode 0755 -end - -template "#{node[:web][:base_directory]}/bin/ruby" do - source "ruby.erb" - owner "root" - group "root" - mode 0755 - notifies :reload, "service[apache2]" -end - -apache_module "passenger" do - conf "passenger.conf.erb" -end - -package "passenger-common#{node[:web][:ruby_version]}" - -munin_plugin "passenger_memory" -munin_plugin "passenger_processes" -munin_plugin "passenger_queues" -munin_plugin "passenger_requests" - template "/etc/cron.hourly/passenger" do cookbook "web" source "passenger.cron.erb" @@ -66,7 +42,7 @@ piwik_configuration = data_bag_item("web", "piwik").to_hash.reject do |k,v| end rails_port "www.openstreetmap.org" do - ruby node[:web][:ruby_version] + ruby node[:passenger][:ruby_version] directory rails_directory user "rails" group "rails" diff --git a/cookbooks/web/templates/default/passenger.conf.erb b/cookbooks/web/templates/default/passenger.conf.erb deleted file mode 100644 index 678b987ed..000000000 --- a/cookbooks/web/templates/default/passenger.conf.erb +++ /dev/null @@ -1,10 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef - - - PassengerRoot /usr - PassengerRuby <%= node[:web][:base_directory] %>/bin/ruby - PassengerUseGlobalQueue on - PassengerMaxPoolSize <%= node[:web][:rails_daemon_limit] %> - PassengerPoolIdleTime 0 - #PassengerMaxPreloaderIdleTime 0 - diff --git a/roles/dev.rb b/roles/dev.rb index ebe2f824d..9e79e0a69 100644 --- a/roles/dev.rb +++ b/roles/dev.rb @@ -95,13 +95,11 @@ default_attributes( }, :apt => { :sources => [ - "brightbox-ruby-ng", "ubuntugis-stable", "mapnik-v210" ] }, :dev => { - :ruby => "1.9.1", :rails => { :master => { :repository => "git://git.openstreetmap.org/rails.git", diff --git a/roles/taginfo.rb b/roles/taginfo.rb index 026d38656..5d0fa4f45 100644 --- a/roles/taginfo.rb +++ b/roles/taginfo.rb @@ -13,9 +13,6 @@ default_attributes( } } }, - :apt => { - :sources => [ "brightbox-ruby-ng" ] - }, :taginfo => { :sites => [ { diff --git a/roles/web-backend.rb b/roles/web-backend.rb index 5cda57edc..91cd6faac 100644 --- a/roles/web-backend.rb +++ b/roles/web-backend.rb @@ -11,8 +11,10 @@ default_attributes( :memcached => { :memory_limit => 4096 }, + :passenger => { + :max_pool_size => 12 + }, :web => { - :rails_daemon_limit => 12, :rails_soft_memory_limit => 512, :rails_hard_memory_limit => 2048 } diff --git a/roles/web-frontend.rb b/roles/web-frontend.rb index 7657b8267..1a7c7ce7a 100644 --- a/roles/web-frontend.rb +++ b/roles/web-frontend.rb @@ -13,8 +13,10 @@ default_attributes( :max_requests_per_child => 10000 } }, + :passenger => { + :max_pool_size => 50 + }, :web => { - :rails_daemon_limit => 50, :rails_soft_memory_limit => 192, :rails_hard_memory_limit => 512 }, diff --git a/roles/web.rb b/roles/web.rb index 04a52e80b..30069f148 100644 --- a/roles/web.rb +++ b/roles/web.rb @@ -10,12 +10,12 @@ default_attributes( } } }, - :apt => { - :sources => [ "brightbox-ruby-ng" ] - }, :nfs => { "/store/rails" => { :host => "ironbelly", :path => "/store/rails" } }, + :passenger => { + :pool_idle_time => 0 + }, :web => { :status => "online", :database_host => "db",