]> git.openstreetmap.org Git - chef.git/commitdiff
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 4279f393b8c424f70c7edfc009c0b1bc1204cdfe..6362520c6927bb5b6aa77853250236ecf241d11e 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 f8098faecd7c22b88e946d44ee2288a416429a47..646b170e27e03b82f1a9120d7c9d0e9a4d900339 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 a7c7421129eb7dadac93811c0043bf931517ba4d..4d962204ec4c8235657cae4d34e8cae6613628db 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 795a69aa06ec10146344bb65abc7d40262ca447b..2ba1d35bef1c3042af91fa2a18aef9dd940521c4 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 bdac494557738d6431cdb019be458f53ce788cb0..b4f487a051720b9d17821b8587a22495f542e132 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 54d692f3126837fc3b74d8aaaf0db38aba439bbb..8ad59e5440da90c27e221518b68e409c94f96424 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 468aea910febe6309209aab9602075057b1a4abe..1ef28bbbb071ed4afeda7c56e99cd486f022fa8b 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 ca27a5081d98478e0988c21b7de21c9408c196a7..1a8ef4122989c1861ba6cddc61e52b6142c65255 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 ebe2f824dc5957507813a8e4129b29437380617b..9e79e0a69f73f093bcaf0fccc446e18566de50ee 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 026d38656f4b0272e54fc11d53d274fd11684719..5d0fa4f45de60a894c5bb6821caca6b05e66e7a4 100644 (file)
@@ -13,9 +13,6 @@ default_attributes(
       }
     }
   },
-  :apt => {
-    :sources => [ "brightbox-ruby-ng" ]
-  },
   :taginfo => {
     :sites => [
       {
index 5cda57edce712a577dad5a4aa8b7e263917d6167..91cd6faacb42085a308b93edb1418e38352f39f9 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 7657b82674384a513ed7bf5110fa4322cc149a31..1a7c7ce7a1e1a08a8efc853767c1d4279f5e5243 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 04a52e80b85187717de5227cc93a537a22c7ba49..30069f1482d60c05d6ee4a227e14a23e11ed8ba6 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",