NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
# (1) copy the newrelic rpm java client into #{RAILS_ROOT}/solr/newrelic | |
# (2) add a newrelic.yml in that directory with you API key | |
# (3) add this monkey patch in an initializer to load newrelic with the solr server | |
Sunspot::Server.class_eval do | |
def run | |
command = ['java'] | |
command << "-Xms#{min_memory}" if min_memory | |
command << "-Xmx#{max_memory}" if max_memory | |
command << "-Djetty.port=#{port}" if port | |
command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir |
PID_DIR = '/srv/myapp/shared/pids' | |
RAILS_ENV = ENV['RAILS_ENV'] = 'production' | |
RAILS_ROOT = ENV['RAILS_ROOT'] = '/srv/myapp/current' | |
BIN_PATH = "/home/rails/.rvm/gems/ree-1.8.7-2010.02/bin" | |
God.log_file = "#{RAILS_ROOT}/log/god.log" | |
God.log_level = :info | |
%w(unicorn resque).each do |config| | |
God.load "#{RAILS_ROOT}/config/god/#{config}.god" |
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
# install git | |
sudo apt-get install g++ curl libssl-dev apache2-utils | |
sudo apt-get install git-core | |
# download the Node source, compile and install it | |
git clone https://github.com/joyent/node.git | |
cd node | |
./configure | |
make | |
sudo make install | |
# install the Node package manager for later use |
module ActiveRecord; class Base; end; end | |
# The AR Models Rails give you | |
class User < ActiveRecord::Base | |
# These fields are defined dynamically by ActiveRecord | |
attr_accessor :id, :full_name | |
end | |
class Discussion < ActiveRecord::Base | |
# These fields are defined dynamically by ActiveRecord |
# https://gist.github.com/1214052 | |
require 'sinatra/base' | |
class ResqueWeb < Sinatra::Base | |
require 'resque/server' | |
use Rack::ShowExceptions | |
if CFG[:user].present? and CFG[:password].present? | |
Resque::Server.use Rack::Auth::Basic do |user, password| | |
user == CFG[:user] && password == CFG[:password] |
#!/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 |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
source "http://rubygems.org" | |
gem "janky", "~>0.9" | |
gem "pg" | |
gem "thin" |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf
using homebrew.