Rails / Deployment

From WhyNotWiki

Jump to: navigation, search

Rails / Deployment  edit   (Category  edit)


Contents

[edit] General

http://manuals.rubyonrails.org/read/chapter/97#page257 Capistrano: Automating Application Deployment |

Ruby on Rails Deployment Group on Google Groups

http://brainspl.at/files/AgileRailsDeployment.pdf : Quite informative

http://gizmoojo.wordpress.com/2006/02/28/6-tips-for-deploying-ruby-on-rails-with-dreamhost/ 6 tips for deploying Ruby on Rails with Dreamhost « Gizmoojo!


[edit] Capistrano

Capistrano edit



Capistrano  edit   (Category  edit)


[edit] Capistrano itself

Simple. The way it should be.


Homepage: http://capify.org/




Description: Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally.





http://capify.org/. Retrieved on 2007-05-11 11:18.


  • Great for automating tasks via SSH on remote servers, like software installation, application deployment, configuration management, ad hoc server monitoring, and more.
  • Ideal for system administrators, whether professional or incidental.
  • Easy to customize. Its configuration files use the Ruby programming language syntax, but you don't need to know Ruby to do most things with Capistrano.
  • Easy to extend. Capistrano is written in the Ruby programming language, and may be extended easily by writing additional Ruby modules.


Old:

[edit] Upgrading from 1 to 2.0

http://capify.org/upgrade Capistrano: Upgrade Guide

Tips for Upgrading to Capistrano 2 | Ruby on Rails for Newbies

[edit] Dissection: Where the tasks are actually implemented

/usr/lib/ruby/gems/1.8/gems/capistrano-1.2.0/lib/capistrano/recipes/standard.rb

task :migrate, :roles => :db, :only => { :primary => true } do
  directory = case migrate_target.to_sym
    when :current then current_path
    when :latest  then current_release
    else
      raise ArgumentError,
        "you must specify one of current or latest for migrate_target"
  end

  run "cd #{directory} && " +
      "#{rake} RAILS_ENV=#{rails_env} #{migrate_env} migrate"
end

task :deploy_with_migrations do
  update_code

  begin
    old_migrate_target = migrate_target
    set :migrate_target, :latest
    migrate
  ensure
    set :migrate_target, old_migrate_target
  end

  symlink

  restart
end

[edit] Troubleshooting: <subversion can't update because directory 'log' was replaced. Please add it to svn:ignore./code>

> rake remote:update_current
...
    loading configuration /usr/lib/ruby/gems/1.8/gems/capistrano-1.2.0/lib/capistrano/recipes/standard.rb
    loading configuration ./config/deploy.rb
    loading configuration /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-0.2.1/lib/mongrel_cluster/recipes.rb
  * executing task update_current
  * querying latest revision...
  * executing "cd ... && svn up -q &&\n            (test -e .../revisions.log || (touch .../revisions.log && chmod 666 /.../revisions.log)) && echo `date +\"%Y-%m-%d %H:%M:%S\"` $USER 2189  >> .../revisions.log;"
    servers: ["....com"]
    [....com] executing command
 ** [out :: ....com] svn: The entry 'log' is no longer a directory; remove the entry before updating
 ** [out :: ....com] subversion can't update because directory 'log' was replaced. Please add it to svn:ignore.
rake aborted!
subversion can't update because directory 'log' was replaced. Please add it to svn:ignore.

Yes, the error message alludes to a possible solution. Unfortunately, it only tells half the story.

I tried doing that (svn ignore is a part of subwrap):

> svn ignore log
> svn commit
> rake remote:update_current

But it still complained with the same error.

Then I tried:

> svn rm log
> svn commit
> rake remote:update_current

But that too did not work... until I "fixed" the working copy with the following "ingenious" trick:

(On the production server:)

.../current> mv log log2
.../current> svn up log
D    log
Updated to revision 2189.
.../current> mv log2 log

Subsequently, this no longer results in an error:

> rake remote:update_current

So I have concluded: You won't be able to svn update your working copy on your production server that is using Capistrano if your log directory is under version control. Your log directory must not be under version control.


[edit] Deprec: deployment recipes for capistrano

Homepage: http://www.deprec.org/
Source code: gem install deprec / http://scm.deprecated.org/var/svn/deprec/trunk/



Description: a collection of automated recipes, written in Ruby, for setting up production ready Ruby on Rails servers. This includes everything from creating admin accounts and setting up your ssh keys to compiling and installing the packages required to get a Rails application running on a freshly installed Ubuntu 6.06.1 LTS server.





deprec - Trac (http://www.deprec.org/). Retrieved on 2007-05-11 11:18.


[edit] Quickstart

cd /path/to/railsapp
deprec --apply-to . 
# edit config/deploy.rb to put in details for:
#  :name       - a short name for your application 
#  :domain     - the domain name it will be served from
#  :repository - your rails applications scm repository
cap install_rails_stack
cap setup
cap deploy_with_migrations
cap restart_apache
 


[edit] Web server

[edit] Mongrel

http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/

http://blog.dgibbons.net/articles/2006/08/08/why-you-need-multiple-mongrel-instances-with-rails

http://bliki.rimuhosting.com/space/knowledgebase/linux/miscapplications/ruby+on+rails RimuHosting Bliki :: knowledgebase/linux/miscapplications/ruby on rails

http://mongrel.rubyforge.org/docs/apache.html Apache Best Practice Deployment

http://blog.kovyrin.net/2006/08/22/high-performance-rails-nginx-lighttpd-mongrel/

[edit] Starting mongrels on boot-up

Start and Stop All Your Mongrel_Cluster Processes (http://www.simplisticcomplexity.com/2006/9/26/start-and-stop-all-your-mongrel_cluster-processes). Retrieved on 2007-03-26 17:02.

So, Its possible to use mongrel cluster in a shared environment. I’ve shown that. But what about stopping and starting all these processes? No one wants to cap restart in every source directory after a server gets rebooted. And what if I need to shut them all down at once!? I can’t be ghetto and sudo killall mongrel_rails, I’ve got self respect.

So to solve my little problem, I took the kick in the butt from Peter Cooper and finally created an init script for all the mongrel_clusters on a shared box.

The beauty of this is that when I add a new app to the server, I don’t have to tell the script. Using conventions, it knows what rails apps I have installed.

Basically, when you call start, it iterates through the APP_DIR directory. When it finds a rails app with mongrel_cluster.conf in its config directory, it starts it, but not before it verifies that there isn’t a pid under /log/. If it finds a pid, it just reports back to you that the app has already been started..

http://code.jtoe.net/rails/scripts/mongrel_processes.rb

[edit] Hosting providers

See/move to: Hosting#Ruby on Rails

http://www.planetargon.com/hosting.html: $11.25/month for high-quality shared hosting.

http://rimuhosting.com/order/startorder.jsp: RimuHosting: $20/month for VPS.

http://rimuhosting.com/vps/aboutvps.jsp

http://engineyard.com/pricing

http://dreamhost.com

[edit] On DreamHost

Rails / On Dreamhost

Facts about Rails / DeploymentRDF feed
Description [Oops! No type defined for attribute]
Personal tools