macworld 2008 - it854 - riding the rails on os x
TRANSCRIPT
-
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
1/59
Riding the Rails on OS X Leopard
IT854
Brian Pittspolibyte.com
1/18/2008
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
2/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
Outline
1 Introduction2 Ruby
OverviewRakeRubyGems
3 RailsHistory
PhilosophyAnatomy
4 DeploymentOverview
MongrelApacheMisc
5 AdministrationCapistrano
MaintenanceScaling
6 Conclusion
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
3/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
Ruby History
An object-oriented, interpreted programming language
First release by Yukihiro Matsumoto in 1995
Inspired by Perl and Smalltalk
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
4/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
Ruby in Leopard
Latest stable release: ruby 1.8.6
In framework form:/System/Library/Frameworks/Ruby.framework/
Interpreter and library are universal binaries
Library is 64-bit too
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
I d i
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
5/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
Rake Overview
Alternative to the make program
Rakefiles are written in pure Ruby
Used to automate many housekeepings tasks in Rails
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
I t d ti
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
6/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
Rake Example
/Users/brian/Rakefile
namespace :macworld do
desc "This task will submit a session proposal"
task :submit_proposal doputs "Submitted Proposal"
end
desc "This task will give the talk"
task :give_talk => :submit_proposal doputs "Gave Talk"
end
end
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
7/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
Rake Example
Output
$ rake macworld:give_talk
(in /Users/brian)
Submitted Proposal
Gave Talk
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
8/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
RubyGems Overview
Rubys packaging system
RubyForge is Rubys equivalent to Perls CPAN
Organized with one gem per directory
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
9/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
RubyGems Examples
List installed gems: gem query local
Search gems: gem search remote FOO
Install the latest version of a gem: gem install remoteinclude-dependencies FOO
Install a specific gem version: add version BAR to above
Update an installed gem: gem update FOO
Show details of a gem: gem specification FOOUninstall a gem: gem uninstall FOO
Uninstall old gems: gem clean
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
10/59
IntroductionRubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
RubyGems on Leopard
RubyGems 0.9.4 is installedPre-installed Gems are under/System/Library/Frameworks/Ruby.framework/
Gems you install are in /Library/Ruby/Gems/1.8
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
11/59
RubyRails
DeploymentAdministration
Conclusion
OverviewRakeRubyGems
Building Gems
Most gems are pure Ruby, but some involve C
Have the Xcode Developer Tools installed
By default Leopard builds universal gems
You can specify the architecture with ARCHFLAGS=-archi386 or -arch ppc
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
12/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Rails History
Extracted by David Heinemeier Hansson from his work on
BasecampFirst public release in July 2004
Agile Web Development with Rails published in September2005
Version 2.0 released December 17 2007
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
13/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Rails Users
A few sites on Rails include
Penny Arcade
CNETs Chow
YellowPages.com
and of course, Twitter
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
14/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Rails Philosophy
Model-View-Controller (MVC)Convention over Configuration (CoC)
Dont Repeat Yourself (DRY)
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionR b
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
15/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Anatomy of Rails
Active Record
Active Resource
Action Pack
Active Support
Action Mailer
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionR b
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
16/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Anatomy of a Rails App
Standard directory structureThree environments
DevelopmentTestProduction
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
17/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
app/
Contains subdirectories with the code for
Controllers
Helpers
Models
Views
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
18/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
config/
Important configuration parameters
database.yml
environment.rb
environment/
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
Hi
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
19/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
config/database.yml
Database connection parameters for the three environments
Sampleproduction:
adapter: mysql
database: chunky_production
username: chunky
host: db.bacon.com
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
Hi t
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
20/59
RubyRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Database Adapters
Available database adapters
DB2
Firebird
Frontbase
MySQL
Openbase
Oracle
Postgres
SQLite
SQL Server
Sybase
Configuration for each variesBrian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
Histor
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
21/59
yRails
DeploymentAdministration
Conclusion
HistoryPhilosophyAnatomy
Installing MySQL
Download and install package from mysql.comRun MySQLStartupItem.pkg
Set environment to ppc or i386
gem install mysql with-mysql-dir=/usr/local/mysql
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
22/59
RailsDeployment
AdministrationConclusion
HistoryPhilosophyAnatomy
Creating Databases
Create databases
CREATE DATABASE chunky development;CREATE DATABASE chunky test;CREATE DATABASE chunky production;
Assign permissions
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRuby
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
23/59
RailsDeployment
AdministrationConclusion
HistoryPhilosophyAnatomy
config/environment.rb
Application-wide settings, such as
Version of Rails
Session Store
Log level
Sample
RAILS_GEM_VERSION = 1.2.6
config.log_level = :debug# create the session table with rake db:sessions:create
config.action_controller.session_store = :active_record_st
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyR il
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
24/59
RailsDeployment
AdministrationConclusion
HistoryPhilosophyAnatomy
Sessions
PStore - default, flat files of serialized dataactive record store - database
drb store - DRb server
mem cache store - memcached
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyR il
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
25/59
RailsDeployment
AdministrationConclusion
yPhilosophyAnatomy
environments/
3 files, one for each environment
Specify options only for that environmentSample
environments/production.rb
config.action controller.consider all request local = false
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
26/59
RailsDeployment
AdministrationConclusion
yPhilosophyAnatomy
db/
Autogenerated schema.rb
Migrations
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
27/59
RailsDeployment
AdministrationConclusion
PhilosophyAnatomy
Migrations
Programatically define changes to databaseRun with rake db:migrateApplied in order
001 create users.rb
class AddUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :name, :string
t.column :age, :integerend
end
def self.down
drop_table :users
end Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
History
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
28/59
RailsDeployment
AdministrationConclusion
PhilosophyAnatomy
doc/
Application documentation in HTML
Generated with rake doc:app
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
HistoryPhil h
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
29/59
RailsDeployment
AdministrationConclusion
PhilosophyAnatomy
lib/
Code that isnt in MVCOften used for shared code
tasks/ for application-specific rake tasks
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
HistoryPhil h
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
30/59
DeploymentAdministration
Conclusion
PhilosophyAnatomy
log/
Log file for each environmentLogs contain exception reports, database queries, profilinginformation, and more
Log level can be debug, info, error, or fatal
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
HistoryPhilosophy
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
31/59
DeploymentAdministration
Conclusion
PhilosophyAnatomy
public/
Document root for Apache
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
HistoryPhilosophy
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
32/59
DeploymentAdministration
Conclusion
PhilosophyAnatomy
script/
Miscellaneous scripts such as
breakpointer
console
runner
process/ - used to control FastCGI
performance/ - benchmarker and profiler
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
D l
HistoryPhilosophy
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
33/59
DeploymentAdministration
Conclusion
PhilosophyAnatomy
test/
Programs and supporting files for
Unit
Functional
Integration
tests.
Run the tests with rake test
First time create the test database with rake db:test:prepare
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
D l t
HistoryPhilosophy
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
34/59
DeploymentAdministration
Conclusion
PhilosophyAnatomy
tmp/
Temporary files
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
Deplo ment
HistoryPhilosophy
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
35/59
DeploymentAdministration
Conclusion
p yAnatomy
vendor/
plugins/
Rails
rake rails:freeze:gemsrake rails:freeze:edgerake rails:unfreeze
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
Deployment
OverviewMongrelApache
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
36/59
DeploymentAdministration
Conclusion
ApacheMisc
Deployment Overview
Considered more complicated than writing a simple Rails app
No working mod ruby for Railscgi = unusably slow
First common approach was FastCGI, but this was unreliable
Current favorite is cluster of mongrel web servers behind a
load balancer
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
Deployment
OverviewMongrelApache
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
37/59
DeploymentAdministration
Conclusion
ApacheMisc
Mongrel Overview
Created by Zed Shaw
HTTP server written in 2500 lines of C and RubyIntended for use as a Rails application server
Start one up with mongrel rails start -e production -d -p3000
Connect at http://bacon.com:3000
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
Deployment
OverviewMongrelApache
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
38/59
DeploymentAdministration
Conclusion
ApacheMisc
Mongrel Clustering
1 Mongrel = 1 Request
A cluster of mongrels = Many requests
mongrel rails cluster::configure -p 3000 -e production -a127.0.0.1 -N 3 -c /var/chunky/current/
Produces config/mongrel cluster.yml which can be furthertweaked
Start cluster with mongrel rails cluster::startMongrels are on 3000, 3001, and 3002
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
Deployment
OverviewMongrelApache
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
39/59
ep oy e tAdministration
Conclusion
pac eMisc
Launchd for Mongrel Cluster
Credit to Jake Schutz
Program
/opt/local/bin/daemondo
ProgramArguments
--label=mongrel_cluster
--start-cmd
/usr/local/bin/mongrel_rails
cluster::start-C
(Path to your Mongrel Cluster config.yml)
-
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
40/59
p yAdministration
Conclusion
pMisc
Launchd for Mongrel Cluster
--stop-cmd
/usr/local/bin/mongrel_rails
cluster::stop
-C
(Path to your Mongrel Cluster config.yml)
-
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
41/59
AdministrationConclusion
Misc
How Many Mongrels?
Average request time * peak request10 per CPU core
Leave some free RAM
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
Deployment
OverviewMongrelApache
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
42/59
AdministrationConclusion
Misc
Apache Overview
Swiss army knife of web servers
Included in OS X
mod proxy balancer
Fast at serving static content
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAd i i i
OverviewMongrelApacheMi
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
43/59
AdministrationConclusion
Misc
Proxy Balancer Definition
BalancerMember http://127.0.0.1.3000
BalancerMember http://127.0.0.1.3001
BalancerMember http://127.0.0.1.3002
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAd i i t ti
OverviewMongrelApacheMi
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
44/59
AdministrationConclusion
Misc
Proxy Configuration
ServerName www.bacon.com
RequestHeader set X_FORWARDED_HOST www.bacon.com
DocumentRoot /var/chunky/current/public
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
OverviewMongrelApacheMisc
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
45/59
AdministrationConclusion
Misc
Proxy Configuration
RewriteEngine On
# Check for static index and cached pages.
RewriteRule ^/$ /index.html [QSA]RewriteRule ^([^.]+)$ $1.html [QSA]
# No static file exists, let Mongrel handle the request
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://chunky%{REQUEST_URI} [P,QSA
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
OverviewMongrelApacheMisc
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
46/59
AdministrationConclusion
Misc
Apps outside of document root
Set mongrels prefix option
If app at http://bacon.com/chunky, prefix is chunky/Add appropriate rewrite rule
RewriteRule ^/chunky(.*)$ balancer://chunky%{REQUEST_URI}
This allows multiple apps under the same domain
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
47/59
AdministrationConclusion
Capistrano Overview
Deployment tool written in Ruby
Allows you to deploy or rollback releases with one commandEach deployment goes into releases/, current/ is symlink tolatest deployment
Retrieves application from SCM, default is subversion
Communicates with servers using ssh
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
48/59
AdministrationConclusion
Capistrano Setup
If config/deploy.rb doesnt exist, run capify /Users/fox/chunkychunky
require mongrel_cluster/recipes
set :application, "chunky"
set :repository, "http://svn.bacon.com/#{application}"
set :scm_username, fox
set :scm_password, proc{Capistrano::CLI.password_prompt(S
set :deploy_to, "/var/#{application}"
set :mongrel_conf, "#{current_path}/config/mongrel_clusterrole :web, "bacon.com"
role :app, "bacon.com"
role :db, "bacon.com" , :primary => true
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
49/59
Conclusion
Running Capistrano
Make sure you can connect to your SCM from your servers
Make sure the user apache and mongrel run as can ready files
created by the user who runs capThe first time, cap deploy:setup
cap deploy
cap deploy:migrations
cap deploy:rollback
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
50/59
Conclusion
Capistrano Callbacks
You can write cap tasks yourself. E.G. perform more tasks after adeployment
deploy.rb
task :symlink_database_yml do
run "ln -sf #{shared_path}/config/database.yml
#{release_path}/config/database.yml"
end
after deploy:update_code, symlink_database_yml
deploy.rb
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
51/59
Conclusion
Email Notifications
You can get email notifications of application errors by
Configuring Active Mailer
Installing the exception notification plugin
Modifying the ApplicationController Class
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
C l i
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
52/59
Conclusion
Configuring Active Mailer
In config/environment.rb
Example
config.action_mailer.delivery_method = :smtpconfig.action_mailer.server_settings = {
:address => "mail.bacon.com",
:port => 25,
:domain => "bacon.com",
}
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
C l i
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
53/59
Conclusion
Configuring exception notification
ruby script/plugin install exception notification
Add include ExceptionNotifiable toapp/controllers/application.rb
Add ExceptionNotifier.exception.recipients =[[email protected], [email protected]] toconfig/environment.rb
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
Conclusion
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
54/59
Conclusion
Housekeeping
Script and automate
Log rollover
Clearing sessions
DB Example
RAILS_ENV=PRODUCTION ./script/runner \
ActiveRecord::Base.connection.delete(
"DELETE FROM sessions WHERE updated_at < now() - 3600")
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
IntroductionRubyRails
DeploymentAdministration
Conclusion
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
55/59
Conclusion
Multiple Apps, One Host
Seperate
mongrel cluster
proxy balancer://
rewrite rule
virtualhost (if multiple domains)
for each app.
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
RubyRails
DeploymentAdministration
Conclusion
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
56/59
Conclusion
One App, Multiple Hosts
Optimize the app
Dedicated database server, more mongrels on your application
serverThe path from here varies
Multiple application servers and dedicated front-end loadbalancer
Beefy database server or replication
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
RubyRails
DeploymentAdministration
Conclusion
CapistranoMaintenanceScaling
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
57/59
Conclusion
Trends to watch
Patches to mongrel (evented mongrel)
Alternate web servers (lighthttp, nginx, swiftiply)Alternate load balancers (pen, pound, balance, haproxy,hardware)
Alternate Ruby implementations (JRuby, Rubinius)
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
Introduction
RubyRails
DeploymentAdministration
Conclusion
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
58/59
Further Reading
Download the presentation (pdf and tex) athttp://polibyte.com
Find related materials tagged as IT854 on del.icio.us
Deploying Rails Applications by Ezra Zygmuntowicz, BruceA. Tate and Clinton Begin
Agile Web Development with Rails by Dave Thomas and
DHH
Brian Pitts polibyte.com Riding the Rails on OS X Leopard
http://find/http://goback/ -
8/14/2019 Macworld 2008 - IT854 - Riding the Rails on OS X
59/59
Ill stick around for questions.
http://find/http://goback/