Skip to content

Instantly share code, notes, and snippets.

$ cat ~/.vimrc.after
"""""""""""""
" B A S I C
"""""""""""""
set wildmenu " fancy command completion menu!
set showcmd " shows incomplete command to the left of the ruler
"""""""""""""""""

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

@teohm
teohm / README.md
Created February 27, 2013 00:38 — forked from chrismo/README.md

On a clean Rails 4 install with Bundler 1.3.0, using --binstubs causes competition between Rails and Bundler for the contents of bin/rails (and bin/rake).

Just running bundle will rewrite the Rails version of bin/rails to a version that doesn't work.

The fix is to use the new bundle binstubs <gemname> command.

(see rails/rails#8974)

# /etc/network/interfaces
auto eth1
iface eth1 inet static
address 33.33.33.55
netmask 255.255.255.0
gateway 33.33.33.11
# given r34 is the bad commit
svn merge -c -34 .
@teohm
teohm / .pkignore
Last active December 10, 2015 23:28
pk team repo example
README.md
@teohm
teohm / ruby-build-1.8.md
Last active December 10, 2015 17:58
ruby-build 1.8.+ on Mac OSX Lion

Modified from https://github.com/sstephenson/ruby-build/wiki

Install XQuartz
Install Homebrew (if you don't have it already)
brew tap homebrew/dupes (repository for duplicate system tools)
brew install apple-gcc42

export CPPFLAGS=-I/opt/X11/include
CONFIGURE_OPTS="--with-readline-dir=/usr/local/Cellar/readline/6.2.4" CC=/usr/local/bin/gcc-4.2 ruby-build -kv 1.8.7-p371 ~/.rubies/ruby-1.8.7-p371
@teohm
teohm / gist:4343392
Created December 20, 2012 06:55 — forked from headius/gist:4343186
system ~/projects/jruby/blah $ jruby ../../startup_bench/lib/tune.rb 1 'touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local'
Beginning tuning for `touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local`
Trying 90 combinations of flags
--------------------------------------------------------------------------------
Last: -J-server
Average time: 8.529s
Overall average: 8.529s
Estimated completion time: 2012-12-19 23:46:27 -0600
--------------------------------------------------------------------------------
Last: -J-client
@teohm
teohm / unicorn
Created December 11, 2012 10:32 — forked from shapeshed/unicorn
Unicorn / Monit setup
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@teohm
teohm / ActiveRepository.rb
Created December 1, 2012 00:09 — forked from bokmann/ActiveRepository.rb
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#