Commit 388d4475 by Vy Quoc Vu

unicorn

parent b0ddaf8e
......@@ -8,6 +8,7 @@ gem 'faker', '1.4.2'
gem 'solr-ruby'
gem 'rsolr'
gem 'unicorn'
gem "unicorn-rails"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
......
......@@ -210,6 +210,9 @@ GEM
kgio (~> 2.6)
rack
raindrops (~> 0.7)
unicorn-rails (2.2.0)
rack
unicorn
vacuum (1.3.0)
jeff (~> 1.0)
multi_xml (~> 0.5.0)
......@@ -250,6 +253,7 @@ DEPENDENCIES
turbolinks
uglifier (>= 1.3.0)
unicorn
unicorn-rails
vacuum
web-console (~> 2.0)
will_paginate-bootstrap
......
set -u
set -e
APP_NAME="Venshopv2"
APP_ROOT="/Venshop/$APP_NAME"
CNF="$APP_ROOT/config/unicorn.rb"
PID="$APP_ROOT/config/shared/pids/unicorn.pid"
ENV=production
UNICORN_OPTS="-D -E $ENV -c $CNF"
old_pid="$PID.oldbin"
cd $APP_ROOT || exit 1
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig () {
test -s $old_pid && kill -$1 `cat $old_pid`
}
case ${1-help} in
start)
sig 0 && echo >&2 "Already running" && exit 0
cd $APP_ROOT ; unicorn_rails $UNICORN_OPTS
;;
stop)
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting instead"
unicorn_rails $UNICORN_OPTS
;;
upgrade)
sig USR2 && exit 0
echo >&2 "Couldn't upgrade, starting instead"
unicorn_rails $UNICORN_OPTS
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
exit 1
;;
esac
</start|stop|restart|upgrade|rotate|force-stop>
app_path = File.expand_path(File.dirname(__FILE__) + '/..')
rails_env = ENV['RAILS_ENV'] || 'production'
worker_processes 4
root = "/Venshop/Venshopv2"
working_directory root
pid "#{root}/config/shared/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/Venshop.sock", :backlog => 64
listen 80, :tcp_nopush => true
timeout 30
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_exec do |_|
ENV['BUNDLE_GEMFILE'] = File.join(root, 'Gemfile')
end
check_client_connection false
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment