Guest User

Untitled

a guest
Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. FILE #### default.rb
  2.  
  3. %w{pcre-devel}.each do |pkg|
  4. package pkg do
  5. action :install
  6. not_if "rpm -qa |grep #{pkg}"
  7. end
  8. end
  9.  
  10. service "nginx" do
  11. supports :restart => true, :status => true, :reload => true
  12. action [:enable, :start]
  13. not_if "ps -ef |grep nginx"
  14. end
  15.  
  16.  
  17. %w{/var/log/nginx/ /var/tmp/ /var/tmp/nginx/ /var/tmp/nginx/client/}.each do |dir|
  18. directory dir do
  19. mode 777
  20. action :create
  21. not_if "test -d #{dir}"
  22. end
  23. end
  24.  
  25. if node.role?("production")
  26. template "/etc/nginx/nginx.conf" do
  27. source "offload_nginx.conf.erb"
  28. mode 0644
  29. if node.role?("frontend")
  30. variables ({
  31. :app_name => "frontend",
  32. :system_env => "www",
  33. :send_timeout => "60",
  34. :client_body_timeout => "60",
  35. :client_header_timeout => "60",
  36. :proxy_read_timeout => "60",
  37. :max_body_size => "1M"
  38. })
  39. elsif node.role?("backend")
  40. variables ({
  41. :app_name => "backend",
  42. :system_env => "backend",
  43. :send_timeout => "240",
  44. :client_body_timeout => "240",
  45. :client_header_timeout => "240",
  46. :proxy_read_timeout => "240",
  47. :max_body_size => "5M"
  48. })
  49. end
  50. end
  51. end
  52.  
  53.  
  54.  
  55. ## File offload_nginx.conf.erb
  56.  
  57.  
  58. server {
  59. listen 80 default;
  60. server_name <%= @system_env %>.mydomain.com;
  61. client_max_body_size <%= @max_body_size %>;
  62.  
  63. # ==========
  64. # Location for Unicorn
  65. # ==========
  66. root /home/nginx/<%= @app_name %>/current/public;
  67.  
  68. }
Add Comment
Please, Sign In to add comment