Revisions
-
keikubo revised this gist
Jun 14, 2012 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Please make sure to replace **sample_app** to your actual Rails project path. Then, just execute the following command. curl -s -L https://gist.github.com/raw/2129714/install.sh | bash Now you may successfully check your Rails application in your browser. Empty file. -
keikubo revised this gist
Jun 13, 2012 . 3 changed files with 18 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,17 @@ #!/usr/bin/env bash DIR=nginx-unicorn SCRIPT_HOME=~/$DIR cd git clone git://gist.github.com/2129714.git $DIR cd $SCRIPT_HOME sed "s#RAILS_ROOT#$RAILS_ROOT#g" $SCRIPT_HOME/nginx.conf > /tmp/nginx.conf sudo cp /tmp/nginx.conf $SCRIPT_HOME/nginx.conf sudo ln -s $SCRIPT_HOME/nginx.conf /usr/local/nginx/conf.d/ export SCRIPT_HOME=$SCRIPT_HOME sudo rm -rf /usr/local/nginx/conf.d/default $SCRIPT_HOME/restart_nginx_and_unicorn.sh rm -rf /tmp/nginx.conf This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,11 @@ upstream backend { server unix:/tmp/.unicorn.sock.1; } log_format default_log '$host $remote_addr [$time_local] "$request" $status $request_length "$http_referer" "$http_user_agent" $request_time'; server { listen 80; server_name _; # all accept access_log /var/log/nginx/access.log default_log; location ~ ^/assets/ { @@ -22,7 +23,7 @@ server { proxy_set_header HOST $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_pass http://backend; proxy_redirect off; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ sudo nginx -s stop sudo nginx pid=`cat $RAILS_ROOT/unicorn.pid` kill -QUIT $pid sleep 1 # unicorn -D -d -E production -c ./script/unicorn.rb unicorn -D -d -E production -c $SCRIPT_HOME/unicorn.rb -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,11 +15,11 @@ Next, check whether you already set $RAILS_ROOT as follows. echo $RAILS_ROOT If you do not set it yet, please do so like below. export RAILS_ROOT=$HOME/sample_app Please make sure to replace **sample_app** to your actual Rails project path. Then, just execute the following command. -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,6 @@ Please make sure that your Gemfile in your rails application includes unicorn. gem 'unicorn' Next, check whether you already set $RAILS_ROOT as follows. echo $RAILS_ROOT -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,10 +11,18 @@ Please make sure that your Gemfile in your rails application includes unicorn. gem 'unicorn' For executing Nginx + Unicorn, please set $RAILS_ROOT first if you do not set it yet. Next, check whether you already set $RAILS_ROOT as follows. echo $RAILS_ROOT If you do not set it yet, please set like below. export RAILS_ROOT=$HOME/sample_app Please make sure that you replace **sample_app** to your actual Rails project path. Then, just execute the following command. bash -s stable < <(curl -s https://raw.github.com/gist/2129714/install.sh) -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,11 @@ This script enables you to launch your Rails application in production environme ## Installation: Please make sure that your Gemfile in your rails application includes unicorn. gem 'unicorn' For executing Nginx + Unicorn, please set $RAILS_ROOT first. export RAILS_ROOT=$HOME/sample_app -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ sudo service nginx restart pid=`cat $RAILS_ROOT/unicorn.pid` kill -QUIT $pid sleep 1 -
keikubo revised this gist
Mar 20, 2012 . 2 changed files with 1 addition and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,6 @@ upstream backend { server unix:/tmp/.unicorn.sock.0; server unix:/tmp/.unicorn.sock.1; } server { This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,9 +6,6 @@ listen "/tmp/.unicorn.sock.0", :backlog => 64 listen "/tmp/.unicorn.sock.1", :backlog => 64 timeout 30 @@ -29,4 +26,4 @@ after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,4 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use [www.apache.org/license/LICENSE-2.0](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. -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ sudo service nginx start pid=`cat $RAILS_ROOT/unicorn.pid` kill -QUIT $pid sleep 1 # unicorn -D -d -E production -c ./script/unicorn.rb -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Now you may successfully check your Rails application in your browser. © 2012 Kei Kubo <[email protected]> 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 [www.apache.org/license/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) -
rackhuber revised this gist
Mar 20, 2012 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ Nginx + Unicorn for Rails on Rackhub ========= ## Description: This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn. ## Installation: First, please set $RAILS_ROOT. export RAILS_ROOT=$HOME/sample_app Then, just execute the following command. bash -s stable < <(curl -s https://raw.github.com/gist/2129714/install.sh) Now you may successfully check your Rails application in your browser. ## Contact © 2012 Kei Kubo <[email protected]> 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 [www.apache.org/license/LICENSE-2.0](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. -
rackhuber revised this gist
Mar 20, 2012 . 3 changed files with 17 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ #!/usr/bin/env bash cd /tmp git clone git://gist.github.com/2129714.git nginx-unicorn cd nginx-unicorn sed "s#RAILS_ROOT#$RAILS_ROOT#g" nginx.conf > /tmp/nginx.conf sudo cp /tmp/nginx.conf /rhb/etc/nginx/conf.d/ ./restart_nginx_and_unicorn.sh rm -rf /tmp/nginx-unicorn rm -rf /tmp/nginx.conf This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ server { access_log /var/log/nginx/access.log default_log; location ~ ^/assets/ { root RAILS_ROOT/public; gzip_static on; # to serve pre-gzipped version expires 1y; add_header Cache-Control public; @@ -28,4 +28,4 @@ server { proxy_pass http://backend; proxy_redirect off; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ sudo service nginx start pid=`cat unicorn.pid` kill -QUIT $pid sleep 1 # unicorn -D -d -E production -c ./script/unicorn.rb unicorn -D -d -E production -c /tmp/nginx-unicorn/unicorn.rb -
keikubo revised this gist
Mar 20, 2012 . 2 changed files with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,2 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ sudo service nginx start pid=`cat unicorn.pid` kill -QUIT $pid sleep 3 -
keikubo revised this gist
Mar 20, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,2 @@ sudo service nginx start ./restart_unicorn.sh -
keikubo created this gist
Mar 20, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ sudo service apache2 stop sudo service nginx start ./restart_unicorn.sh This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ upstream backend { server unix:/tmp/.unicorn.sock.0; server unix:/tmp/.unicorn.sock.1; server unix:/tmp/.unicorn.sock.2; server unix:/tmp/.unicorn.sock.3; } server { listen 80; server_name _; # all accept log_format default_log '$host $remote_addr [$time_local] "$request" $status $request_length "$http_referer" "$http_user_agent" $request_time'; access_log /var/log/nginx/access.log default_log; location ~ ^/assets/ { root $RAILS_ROOT; gzip_static on; # to serve pre-gzipped version expires 1y; add_header Cache-Control public; add_header ETag ""; break; } location / { proxy_set_header HOST $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://backend; proxy_redirect off; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ pid=`cat unicorn.pid` kill -QUIT $pid sleep 3 unicorn -D -d -E production -c ./unicorn.rb This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ rails_root = ENV["RAILS_ROOT"] worker_processes 4 working_directory rails_root # available in 0.94.0+ listen "/tmp/.unicorn.sock.0", :backlog => 64 listen "/tmp/.unicorn.sock.1", :backlog => 64 listen "/tmp/.unicorn.sock.2", :backlog => 64 listen "/tmp/.unicorn.sock.3", :backlog => 64 listen 8000, :tcp_nopush => true timeout 30 pid rails_root + "/unicorn.pid" stderr_path rails_root + "/log/unicorn.stderr.log" stdout_path rails_root + "/log/unicorn.stdout.log" preload_app true GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end