Skip to content

Instantly share code, notes, and snippets.

set :stage, 'production'
set :shared_children, shared_children << 'tmp/sockets'
puma_sock = "unix://#{shared_path}/sockets/puma.sock"
puma_control = "unix://#{shared_path}/sockets/pumactl.sock"
puma_state = "#{shared_path}/sockets/puma.state"
puma_log = "#{shared_path}/log/puma-#{stage}.log"
namespace :deploy do
desc "Start the application"
@docunext
docunext / redirect_to_tld.rb
Created September 6, 2012 18:49 — forked from stevenwilkin/redirect_to_tld.rb
Rack middleware to ensure all traffic is served from a canonical domain
# ensure all requests are served from a canonical top-level-domain
#
# the following in your config.ru will cause all traffic to stevenwilkin.co.uk to
# be redirected to stevenwilkin.com if both domains are served by the same app
#
# require 'redirect_to_tld'
# use RedirectToTLD, 'stevenwilkin.com'
#
class RedirectToTLD
# Hi! I'am rack middleware!
# I was born for show right way to you JavaScript
# My author's name was Aleksandr Koss. Mail him at kossnocorp@gmail.com
# Nice to MIT you!
require(File.dirname(__FILE__) + '/../config/environment') unless defined?(Rails)
class RoutesJs
def initialize app, options = {}
require "erb"
require "redis"
module Rack
class Out
DEFAULTS = { :secret => "secretive-secret", :key => "rack:out",
:host => "127.0.0.1", :port => 6379, :db => 0, :timeout => 5, :password => nil,
:logger => nil, :thread_safe => nil }
def initialize(app, options = {})
@docunext
docunext / gist:3330855
Created August 12, 2012 09:27 — forked from bonyiii/gist:986407
rails 3 w unicorn to log into console
https://gist.github.com/983588
#Put this in application.rb, or in a rake task initialize code
if defined?(Rails) && (Rails.env == 'development')
Rails.logger = Logger.new(STDOUT)
end
@docunext
docunext / unicorn_init_script.sh
Created August 12, 2012 09:23 — forked from romaimperator/unicorn_init_script.sh
This file is an Ubuntu init script for Unicorn
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
@docunext
docunext / README.md
Created August 11, 2012 23:26
Download data from production database to development using Replicate [Ruby on Rails]

Overview

Replicate is a Gem that lets you dump and load relational objects between Ruby/Ruby on Rails environments, e.g. dump data from your production database and load it in your development database.

The examples given in the README are of shell scripts being used to do this. I wanted to use a Capistrano task because it keeps everything related to the production site in one place (particularly the config).

Note: This is tested on a relatively small data set yet it still took about 20 seconds to run - YMMV!

Usage

  • Add the code below to your config/deploy.rb
  • Alter the code = ENV["DATA"] || "User.all; Project.all" line to list all the data you want dumped by default