Move passenger configuration to a separate cookbook
authorTom Hughes <tom@compton.nu>
Mon, 10 Feb 2014 18:42:18 +0000 (18:42 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 10 Feb 2014 18:44:12 +0000 (18:44 +0000)
20 files changed:
cookbooks/dev/metadata.rb
cookbooks/dev/recipes/default.rb
cookbooks/dev/templates/default/passenger.conf.erb [deleted file]
cookbooks/passenger/README.md [new file with mode: 0644]
cookbooks/passenger/attributes/default.rb [new file with mode: 0644]
cookbooks/passenger/metadata.rb [new file with mode: 0644]
cookbooks/passenger/recipes/default.rb [new file with mode: 0644]
cookbooks/passenger/templates/default/passenger.conf.erb [new file with mode: 0644]
cookbooks/passenger/templates/default/ruby.erb [moved from cookbooks/web/templates/default/ruby.erb with 65% similarity]
cookbooks/taginfo/metadata.rb
cookbooks/taginfo/recipes/default.rb
cookbooks/web/attributes/default.rb
cookbooks/web/metadata.rb
cookbooks/web/recipes/rails.rb
cookbooks/web/templates/default/passenger.conf.erb [deleted file]
roles/dev.rb
roles/taginfo.rb
roles/web-backend.rb
roles/web-frontend.rb
roles/web.rb

index 4279f39..6362520 100644 (file)
@@ -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"
index f8098fa..646b170 100644 (file)
@@ -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 (file)
index 42639f1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-<IfModule mod_passenger.c>
-  PassengerRoot /usr
-  PassengerRuby /usr/bin/ruby<%= node[:dev][:ruby] %>
-  PassengerUseGlobalQueue on
-</IfModule>
diff --git a/cookbooks/passenger/README.md b/cookbooks/passenger/README.md
new file mode 100644 (file)
index 0000000..2057391
--- /dev/null
@@ -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 (file)
index 0000000..0c1c8ec
--- /dev/null
@@ -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 (file)
index 0000000..bad97ca
--- /dev/null
@@ -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 (file)
index 0000000..6656ce3
--- /dev/null
@@ -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 (file)
index 0000000..a234b15
--- /dev/null
@@ -0,0 +1,9 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+<IfModule mod_passenger.c>
+  PassengerRoot /usr
+  PassengerRuby /usr/local/bin/passenger-ruby
+  PassengerUseGlobalQueue on
+  PassengerMaxPoolSize <%= node[:passenger][:max_pool_size] %>
+  PassengerPoolIdleTime <%= node[:passenger][:pool_idle_time] %>
+</IfModule>
similarity index 65%
rename from cookbooks/web/templates/default/ruby.erb
rename to cookbooks/passenger/templates/default/ruby.erb
index a7c7421..4d96220 100644 (file)
@@ -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] %> "$@"
index 795a69a..2ba1d35 100644 (file)
@@ -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",
index bdac494..b4f487a 100644 (file)
@@ -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}"
index 54d692f..8ad59e5 100644 (file)
@@ -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"
index 468aea9..1ef28bb 100644 (file)
@@ -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"
index ca27a50..1a8ef41 100644 (file)
@@ -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 (file)
index 678b987..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-<IfModule mod_passenger.c>
-  PassengerRoot /usr
-  PassengerRuby <%= node[:web][:base_directory] %>/bin/ruby
-  PassengerUseGlobalQueue on
-  PassengerMaxPoolSize <%= node[:web][:rails_daemon_limit] %>
-  PassengerPoolIdleTime 0
-  #PassengerMaxPreloaderIdleTime 0
-</IfModule>
index ebe2f82..9e79e0a 100644 (file)
@@ -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",
index 026d386..5d0fa4f 100644 (file)
@@ -13,9 +13,6 @@ default_attributes(
       }
     }
   },
-  :apt => {
-    :sources => [ "brightbox-ruby-ng" ]
-  },
   :taginfo => {
     :sites => [
       {
index 5cda57e..91cd6fa 100644 (file)
@@ -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
   }
index 7657b82..1a7c7ce 100644 (file)
@@ -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
   },
index 04a52e8..30069f1 100644 (file)
@@ -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",