Skip to content

Instantly share code, notes, and snippets.

View marcosanson's full-sized avatar

Marco Sanson marcosanson

View GitHub Profile
require 'garner'
module Mongoid
module Document
module ClassMethods
# Find instances by ID or crtieria in the same order as the IDs provided.
# TODO: this can be done with an $or until MongoDB 2.6, see https://jira.mongodb.org/browse/SERVER-14083
def find_ordered(ids, criteria = nil)
return [] if ids.empty?
instances = criteria || self.find(ids)
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true