passenger-nginx.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #
  2. # Cookbook Name:: application
  3. # Recipe:: default
  4. #
  5. # Copyright 2009, 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 "passenger_enterprise::nginx"
  21. template "#{node[:nginx][:dir]}/sites-available/#{app['id']}.conf" do
  22. source "rails_nginx_passenger.conf.erb"
  23. owner "root"
  24. group "root"
  25. mode "0644"
  26. variables(
  27. :app => app['id'],
  28. :docroot => "/srv/#{app['id']}/current/public",
  29. :server_name => "#{app['id']}.#{node[:domain]}",
  30. :server_aliases => [ node[:fqdn], app['id'] ],
  31. :rails_env => app['environment']
  32. )
  33. end
  34. nginx_site "#{app['id']}.conf" do
  35. notifies :restart, resources(:service => "nginx")
  36. end
  37. d = resources(:deploy => app['id'])
  38. d.restart_command do
  39. service "nginx" do action :restart; end
  40. end