passenger_apache2.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #
  2. # Cookbook Name:: application
  3. # Recipe:: passenger_apache2
  4. #
  5. # Copyright 2010, Opscode, Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. app = node.run_state[:current_app]
  20. include_recipe "apache2"
  21. include_recipe "apache2::mod_ssl"
  22. include_recipe "apache2::mod_rewrite"
  23. include_recipe "passenger_apache2::mod_rails"
  24. server_aliases = [ "#{app['id']}.#{node[:domain]}", node.fqdn ]
  25. if node.has_key?("ec2")
  26. server_aliases << node.ec2.public_hostname
  27. end
  28. web_app app['id'] do
  29. docroot "#{app['deploy_to']}/current/public"
  30. template "#{app['id']}.conf.erb"
  31. cookbook "#{app['id']}"
  32. server_name "#{app['id']}.#{node[:domain]}"
  33. server_aliases server_aliases
  34. log_dir node[:apache][:log_dir]
  35. rails_env node.chef_environment
  36. end
  37. if ::File.exists?(::File.join(app['deploy_to'], "current"))
  38. d = resources(:deploy_revision => app['id'])
  39. d.restart_command do
  40. service "apache2" do action :restart; end
  41. end
  42. end
  43. apache_site "000-default" do
  44. enable false
  45. end