Skip to content

Instantly share code, notes, and snippets.

@lawrencecurtis
Created July 29, 2010 09:27
Show Gist options
  • Save lawrencecurtis/497715 to your computer and use it in GitHub Desktop.
Save lawrencecurtis/497715 to your computer and use it in GitHub Desktop.
Settings are listed in order of priority. The top value will be used.
disable_shared_gems
Set for your local app (/Users/lawrencecurtis/code/chale/.bundle/config): "1"
without
Set for your local app (/Users/lawrencecurtis/code/chale/.bundle/config): ""
path
Set via $BUNDLE_BUNDLE_PATH: "/Users/lawrencecurtis/.rvm/gems/ruby-1.8.7-p174"
source :gemcutter
gem 'rails', :git => "git://github.com/rails/rails.git"
gem 'thinking-sphinx',
:git => 'git://github.com/freelancing-god/thinking-sphinx.git',
:branch => 'rails3',
:require => 'thinking_sphinx'
gem 'mysql'
gem 'RedCloth'
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'
gem 'cancan'
gem 'state_machine', :git => "git://github.com/pluginaweek/state_machine.git"
gem 'memcache-client'
#gem 'newrelic_rpm', :git => "git://github.com/newrelic/rpm.git", :branch => '2.13.0_dev' # rails 3 version coming @ railsconf
gem "nokogiri"
gem 'rmagick', '2.11.1', :require => 'RMagick'
gem 'prawn'
gem 'wirble'
gem "annotate"
gem "unicorn"
gem "bundler"
gem 'newrelic_rpm', :git => "git://github.com/newrelic/rpm.git", :branch => '2.13.0_dev'
gem "will_paginate", :git => "git://github.com/mislav/will_paginate.git", :branch => "rails3"
GIT
remote: git://github.com/freelancing-god/thinking-sphinx.git
revision: 5fe4a03
branch: rails3
specs:
thinking-sphinx (2.0.0.rc1)
activerecord (>= 3.0.0.beta3)
riddle (>= 1.0.10)
GIT
remote: git://github.com/mislav/will_paginate.git
revision: 60aa1c7
branch: rails3
specs:
will_paginate (3.0.pre)
GIT
remote: git://github.com/newrelic/rpm.git
revision: 828bb5d
branch: 2.13.0_dev
specs:
newrelic_rpm (2.13.0.beta6)
GIT
remote: git://github.com/odorcicd/authlogic.git
revision: a087ad0
branch: rails3
specs:
authlogic (2.1.3)
activesupport
GIT
remote: git://github.com/pluginaweek/state_machine.git
revision: 10a1784
specs:
state_machine (0.9.3)
GIT
remote: git://github.com/rails/rails.git
revision: 06b9531
specs:
actionmailer (3.0.0.rc)
actionpack (= 3.0.0.rc)
mail (~> 2.2.5)
actionpack (3.0.0.rc)
activemodel (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-mount (~> 0.6.9)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.22)
activemodel (3.0.0.rc)
activesupport (= 3.0.0.rc)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0.rc)
activemodel (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
arel (~> 0.4.0)
tzinfo (~> 0.3.22)
activeresource (3.0.0.rc)
activemodel (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
activesupport (3.0.0.rc)
rails (3.0.0.rc)
actionmailer (= 3.0.0.rc)
actionpack (= 3.0.0.rc)
activerecord (= 3.0.0.rc)
activeresource (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
bundler (>= 1.0.0.rc.1)
railties (= 3.0.0.rc)
railties (3.0.0.rc)
actionpack (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
rake (>= 0.8.3)
thor (~> 0.14.0)
GEM
remote: http://rubygems.org/
specs:
RedCloth (4.2.3)
abstract (1.0.0)
annotate (2.4.0)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
builder (2.1.2)
cancan (1.2.0)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.1)
mail (2.2.5)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
memcache-client (1.8.5)
mime-types (1.16)
mysql (2.8.1)
nokogiri (1.4.2)
polyglot (0.3.1)
prawn (0.8.4)
prawn-core (>= 0.8.4, < 0.9)
prawn-layout (>= 0.8.4, < 0.9)
prawn-security (>= 0.8.4, < 0.9)
prawn-core (0.8.4)
prawn-layout (0.8.4)
prawn-security (0.8.4)
rack (1.2.1)
rack-mount (0.6.9)
rack (>= 1.0.0)
rack-test (0.5.4)
rack (>= 1.0)
rake (0.8.7)
riddle (1.0.11)
rmagick (2.11.1)
thor (0.14.0)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.22)
unicorn (1.1.2)
rack
wirble (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
RedCloth
annotate
authlogic!
bundler
cancan
memcache-client
mysql
newrelic_rpm!
nokogiri
prawn
rails!
rmagick (= 2.11.1)
state_machine!
thinking-sphinx!
unicorn
will_paginate!
wirble
# unicorn -c config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'development'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 2 : 1)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
# Restart any workers that haven't responded in 30 seconds
timeout 30
rails_root = File.dirname(__FILE__).split("/")
rails_root.pop
puts File.join(rails_root)
# rails_root = File.join(dir)
# Listen on a Unix data socket
# listen Rails.root'/Users/lawrencecurtis/code/tacktick/tmp/sockets/unicorn.sock', :backlog => 2048
listen File.join(rails_root, "tmp/pids/unicorn.sock"), :backlog => 2048
pid File.join(rails_root, "tmp/pids/unicorn.pid")
stdout_path File.join(rails_root, "log/unicorn.log")
stderr_path File.join(rails_root, "log/unicorn.error.log")
if rails_env == "development"
listen 3000, :tcp_nopush => true
end
##
# REE
# http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# The following is only recommended for memory/DB-constrained
# installations. It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# This allows a new master process to incrementally
# phase out the old master process with SIGTTOU to avoid a
# thundering herd (especially in the "preload_app false" case)
# when doing a transparent upgrade. The last worker spawned
# will then kill off the old master process with a SIGQUIT.
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
# *optionally* throttle the master from forking too quickly by sleeping
sleep 1
end
after_fork do |server, worker|
##
# Unicorn master loads the app then forks off workers - because of the way
# Unix forking works, we need to make sure we aren't using any of the parent's
# sockets, e.g. db connection
# CHIMNEY.client.connect_to_server
# Redis and Memcached would go here but their connections are established
# on demand, so the master never opens a socket
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
##
# Unicorn master is started as root, which is fine, but let's
# drop the workers to git:git
begin
uid, gid = Process.euid, Process.egid
user, group = 'deploy', 'deploy'
target_uid = Etc.getpwnam(user).uid
target_gid = Etc.getgrnam(group).gid
worker.tmp.chown(target_uid, target_gid)
if uid != target_uid || gid != target_gid
Process.initgroups(user, target_gid)
Process::GID.change_privilege(target_gid)
Process::UID.change_privilege(target_uid)
end
rescue => e
if Rails.env == 'development'
STDERR.puts "couldn't change user, oh well"
else
# raise e
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment