Commit 8de7fa5

mo khan <mo@mokhan.ca>
2015-05-24 03:20:07
update path to puma socket file and nginx reverse proxy config.
1 parent 57b0036
Changed files (4)
attributes/default.rb
@@ -10,7 +10,8 @@ default['delayed_job']['current_path'] = "#{node['capistrano']['root_path']}/cur
 default['delayed_job']['rails_env'] = node.chef_environment
 default['nginx']['domain'] = 'www.example.com'
 default['nginx']['current_path'] = "#{node['capistrano']['root_path']}/current"
-default['nginx']['shared_path'] = "#{node['capistrano']['root_path']}/shared_path"
+default['nginx']['shared_path'] = "#{node['capistrano']['root_path']}/shared"
+default['nginx']['socket_file'] = "#{node['capistrano']['root_path']}/shared/tmp/sockets/puma.sock"
 default['nginx']['ssl']['key'] = <<-DATA
 -----BEGIN RSA PRIVATE KEY-----
 MIICWwIBAAKBgQCbfQuXVpccfpOmBHGfkZVfgfOZpMLGX3XmxFrer20aGM6vG9JR
@@ -54,6 +55,9 @@ DATA
 default['unicorn']['username'] = node['user']['username']
 default['unicorn']['current_path'] = "#{node['capistrano']['root_path']}/current"
 default['unicorn']['rails_env'] = node.chef_environment
+default['puma']['username'] = node['user']['username']
+default['puma']['current_path'] = "#{node['capistrano']['root_path']}/current"
+default['puma']['rails_env'] = node.chef_environment
 default['monit']['application'] = 'app'
 #default['rbenv']['ruby_version'] = '2.2.2'
 default['rbenv']['rubies'] = [ "2.2.2" ]
templates/default/nginx_unicorn.erb
@@ -1,9 +1,5 @@
-upstream unicorn {
-  server unix:<%= @shared_path %>/sockets/unicorn.sock fail_timeout=0;
-}
-
-upstream puma {
-  server localhost:5000;
+upstream backend {
+  server unix:<%= @socket_file %> fail_timeout=0;
 }
 
 client_max_body_size 4G;
@@ -37,20 +33,20 @@ server {
     rewrite  ^/(.*)$  https://<%= @domain %>/$1  permanent;
   }
 
-  try_files $uri/index.html $uri @unicorn;
+  try_files $uri/index.html $uri @application;
   location ^~ /assets/ {
     gzip_static on;
     expires max;
     add_header Cache-Control public;
   }
 
-  location @unicorn {
+  location @application {
     proxy_set_header X_FORWARDED_PROTO https;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header HOST $http_host;
-    proxy_set_header  X-Url-Scheme $scheme;
+    proxy_set_header X-Url-Scheme $scheme;
     proxy_redirect off;
-    proxy_pass http://puma;
+    proxy_pass http://backend;
   }
 
   error_page 500 502 503 504 /500.html;
templates/default/puma.conf.erb
@@ -1,1 +1,1 @@
-<%= @current_path %>,<%= @username %>,<%= @current_path %>/config/puma.rb,<%= @current_path %>/log/puma.log
+<%= @current_path %>,<%= @username %>,<%= @current_path %>/config/puma_production.rb,<%= @current_path %>/log/puma.log
templates/default/puma.erb
@@ -53,7 +53,7 @@ do_start() {
 }
 
 do_start_one() {
-  PIDFILE=$1/tmp/puma/pid
+  PIDFILE=$1/tmp/pids/puma.pid
   if [ -e $PIDFILE ]; then
     PID=`cat $PIDFILE`
     # If the puma isn't running, run it, otherwise restart it.
@@ -97,7 +97,7 @@ do_stop() {
 #
 do_stop_one() {
   log_daemon_msg "--> Stopping $1"
-  PIDFILE=$1/tmp/puma/pid
+  PIDFILE=$1/tmp/pids/puma.pid
   STATEFILE=$1/tmp/puma/state
   if [ -e $PIDFILE ]; then
     PID=`cat $PIDFILE`
@@ -129,7 +129,7 @@ do_restart() {
 # Function that sends a SIGUSR2 to the daemon/service
 #
 do_restart_one() {
-  PIDFILE=$1/tmp/puma/pid
+  PIDFILE=$1/tmp/pids/puma.pid
   i=`grep $1 $CONFIG`
   dir=`echo $i | cut -d , -f 1`
   
@@ -169,7 +169,7 @@ do_status() {
 # Function that sends a SIGUSR2 to the daemon/service
 #
 do_status_one() {
-  PIDFILE=$1/tmp/puma/pid
+  PIDFILE=$1/tmp/pids/puma.pid
   i=`grep $1 $CONFIG`
   dir=`echo $i | cut -d , -f 1`