Skip to content

Instantly share code, notes, and snippets.

View dwradcliffe's full-sized avatar

David Radcliffe dwradcliffe

View GitHub Profile

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:

@andrew
andrew / railscheck.rb
Last active December 10, 2015 20:59
Check your github account for out of date rails apps
## Rails Upgrade check
#
# Check your github repos for out of date rails apps
#
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ruby railscheck.rb
# or
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ORG=yourorgname ruby railscheck.rb
#
# n.b requires the octokit gem
@kasima
kasima / nest.coffee
Created December 14, 2012 22:53
hubot, make it cozy
# Description:
# Control your nest thermostat.
#
# Commands:
# hubot how (warm|cold) is it - current temperature
# hubot it's warm - set the nest 1 degree Fahrenheit lower
# hubot it's cold - set the nest 1 degree Fahrenheit higher
# hubot nest status - current nest setting
# https://github.com/kasima/nesting
@eric
eric / _deploy.rb
Created May 29, 2012 06:00
Capistrano notification for Boundary
# load plugin
load 'boundary'
# Notify boundary with your orgid, apikey
boundary.register 'cdd7261592bca18539eae9bb5f1bcfdd', 'f9e6282c4727c5733585a4be86e0f990'
@NickJosevski
NickJosevski / myview.js.coffee
Created March 8, 2012 00:36 — forked from tarnacious/myview.js.coffee
backbone example - serialize form + update on change
window.MyView = Backbone.View.extend({
initialize: ->
_.bindAll(this,'render')
this.template = window.JST["MyView"]
this.model.bind('change', this.render)
render: ->
$(this.el).html(this.template(this.model.toJSON()))
events: {
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@brentkirby
brentkirby / service
Created June 22, 2011 08:50
Unicorn + Runit + RVM
#!/bin/bash -e
#
# Since unicorn creates a new pid on restart/reload, it needs a little extra love to
# manage with runit. Instead of managing unicorn directly, we simply trap signal calls
# to the service and redirect them to unicorn directly.
#
# To make this work properly with RVM, you should create a wrapper for the app's gemset unicorn.
#
function is_unicorn_alive {
@jstorimer
jstorimer / 016_session_store.rb
Created November 17, 2010 21:14
Multiple session store implementation
RedisSessionStore.logger = Rails.logger
session_options = {:expire_after => 1.day, :key_prefix => 'sessions'}
MultiSessionStore.stores[:plain] = [RedisSessionStore, session_options.merge(:key => '_session_id')]
MultiSessionStore.stores[:secure] = [RedisSessionStore, session_options.merge(:key => '_secure_session_id', :secure => ['production', 'staging'].include?(Rails.env))]
MultiSessionStore.default_store = :plain
MultiSessionStore.routes = [
['/admin', :secure],
]
@apsoto
apsoto / update_cache.rake
Created August 4, 2010 20:53 — forked from mdkent/update_cache.rake
Sync Chef Cookbooks and Roles with Server
#
# Tasks to keep your repository in sync with your Chef Server
#
# Author:: Matthew Kent (<mkent@magoazul.com>)
# Copyright:: Copyright (c) 2010 Matthew Kent
# License:: Apache License, Version 2.0
#
# 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
@bkeepers
bkeepers / gist:480948
Created July 19, 2010 02:32
// hack to get which button was clicked
$('input[type=submit], button').live('click', function() {
$('<input type="hidden" class="button" />')
.attr({name:this.name, value:this.value || this.innerHTML})
.appendTo(this.form);
});
$('form').live('reset', function() {
$(this).find('input[type=hidden].button').remove();
});