| 1 |
------------------------------------------ |
|---|
| 2 |
deprec - Deployment Recipes for Capistrano |
|---|
| 3 |
------------------------------------------ |
|---|
| 4 |
|
|---|
| 5 |
QUICKSTART |
|---|
| 6 |
|
|---|
| 7 |
To get your rails app running on a stock standard Ubuntu 6.06 server: |
|---|
| 8 |
|
|---|
| 9 |
cd /path/to/railsapp |
|---|
| 10 |
deprec --apply-to . |
|---|
| 11 |
# edit config/deploy.rb to put in details for: |
|---|
| 12 |
# :name - a short name for your application |
|---|
| 13 |
# :domain - the domain name it will be served from |
|---|
| 14 |
# :repository - your rails applications scm repository |
|---|
| 15 |
cap install_rails_stack |
|---|
| 16 |
cap setup |
|---|
| 17 |
cap deploy_with_migrations |
|---|
| 18 |
cap restart_apache |
|---|
| 19 |
|
|---|
| 20 |
Read on for installation and usage instructions. |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
WHAT DEPREC IS |
|---|
| 24 |
|
|---|
| 25 |
Deprec is a collection of automated recipes, written in ruby, for setting up production ready rails servers. The idea is, even if it takes longer to write a general recipe for your situation, rather than just doing it by hand, |
|---|
| 26 |
it's well worth the effort because you get a reliable and reproducible deployment that will work just as well even if it's 3am and a human would be liable to make mistakes with live webservers. |
|---|
| 27 |
|
|---|
| 28 |
You also get the advantage of a further set of conventions, which means that other tools that you write can build on these conventions, in the same way that the conventions that we already have amongst rails and capistrano users |
|---|
| 29 |
benefit us when writing plugins and gems. |
|---|
| 30 |
|
|---|
| 31 |
Deprec is designed to take a raw server, and set it up with current best practices for a production web server. Until recently this has meant Apache 2.2 for load balancing and static content, and Mongrel for serving rails. The default setup will soon be changed, with nginx replacing apache. A convention over configuration approach will be followed so Apache will be available to those who still wish to use it. |
|---|
| 32 |
|
|---|
| 33 |
Version 1.x of deprec contains recipes specifically for default installations of Ubuntu 6.06 (server). Version 2.x of deprec (currently being worked on) will extract all ubuntu specific code to a plugin, alowing others to easily write thrid party plugins to get deprec working on other distros (and even OS's). [http://dev.deprec.org/trac.cgi/browser/trunk/ROADMAP.txt deprec roadmap] |
|---|
| 34 |
|
|---|
| 35 |
Deprec also contains tasks which will allow it to be used on slightly non-standard ubuntu installations, such as those provided by slicehost.com. |
|---|
| 36 |
|
|---|
| 37 |
Deprec has been tested on live VPS hosts with real production sites. It works for me, if it doesn't work for you, then it's easy to extend. |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
WHAT DEPREC ISN'T |
|---|
| 41 |
|
|---|
| 42 |
Deprec isn't an attempt to solve all problems on all servers. I am solving my own deployment problems, and providing a general framework to help you solve yours. I'm currently working on deprec2.0 which will make it easy for others to write plugin support for other linux distributions. |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
CREDITS |
|---|
| 46 |
|
|---|
| 47 |
Deprec is written and maintained by Mike Bailey <mike@bailey.net.au>. |
|---|
| 48 |
More about me here: [http://mike.bailey.net.au/] |
|---|
| 49 |
|
|---|
| 50 |
Deprec was inspired and uses the brilliantly executed Capistrano. Thanks Jamis! |
|---|
| 51 |
|
|---|
| 52 |
After starting on this project I found myself reading and utilizing a lot of |
|---|
| 53 |
code by Bradley Taylor (RailsMachine gem) and Neil Wilson (vmbuilder_plugins gem). |
|---|
| 54 |
|
|---|
| 55 |
I'd like to say a huge thanks to these guys for helping make my work easier! |
|---|
| 56 |
|
|---|
| 57 |
For the first cut I have included all third party code in a directory within |
|---|
| 58 |
the deprec gem, rather than link to the gems themselves. I made this decision |
|---|
| 59 |
to prevent deprec from breaking due to a change in one of the other libraries. |
|---|
| 60 |
|
|---|
| 61 |
Thanks to Craig Ambrose for help with testing, documentation and beer. |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
LICENCE |
|---|
| 65 |
|
|---|
| 66 |
Deprec is licenced under the GPL. This means that you can use it in commercial |
|---|
| 67 |
or open source applications. More details found here: |
|---|
| 68 |
http://www.gnu.org/licenses/gpl.html |
|---|
| 69 |
|
|---|
| 70 |
deprec - deployment recipes for capistrano |
|---|
| 71 |
Copyright (C) 2006 Mike Bailey |
|---|
| 72 |
|
|---|
| 73 |
This program is free software; you can redistribute it and/or |
|---|
| 74 |
modify it under the terms of the GNU General Public License |
|---|
| 75 |
as published by the Free Software Foundation; either version 2 |
|---|
| 76 |
of the License, or (at your option) any later version. |
|---|
| 77 |
|
|---|
| 78 |
This program is distributed in the hope that it will be useful, |
|---|
| 79 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 80 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 81 |
GNU General Public License for more details. |
|---|
| 82 |
|
|---|
| 83 |
You should have received a copy of the GNU General Public License |
|---|
| 84 |
along with this program; if not, write to the Free Software |
|---|
| 85 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
USAGE |
|---|
| 89 |
|
|---|
| 90 |
The following instructions describe how to use deprec. |
|---|
| 91 |
|
|---|
| 92 |
Most of the magic of deprec occurs in the install_rails_stack section. This builds the server, which developers previously had to do by hand, or find a hosting company that did it for them. Once that is done, deprec also adds application specific helper tasks, which are shown below in the "deploy a rails app to hosts" section. |
|---|
| 93 |
|
|---|
| 94 |
Please note that the "deprec --apply-to" command is much like the "cap --apply-to" command, except that it creates a deploy.rb file in your application's config directory with more available settings than capistrano uses, because these settings can be used to configure the application specific aspects of apache and mongrel. |
|---|
| 95 |
|
|---|
| 96 |
Important Note: |
|---|
| 97 |
Running "deprec --apply-to" currently overwrites your existing deploy.rb file. If you have deployed the app elsewhere before, you may want to backup this file so that you can refer to it when setting up your deprec generated deploy.rb. Because deprec sets up the server, it can fill in more sensible defaults than capistrano normally does, but there are still a few settings that you need to set yourself. Future versions of deprec will not overwrite this file automatically, but will move it out of the way first. |
|---|
| 98 |
|
|---|
| 99 |
## install deprec on workstation |
|---|
| 100 |
# |
|---|
| 101 |
sudo gem install deprec -y # installs what you need |
|---|
| 102 |
echo "require 'deprec/recipes'" >> ~/.caprc # include deprec recipes |
|---|
| 103 |
cap show_tasks # should now include deprec tasks |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
## install rails stack |
|---|
| 107 |
# |
|---|
| 108 |
# this currently only works with ubuntu 6.06.1 server installed |
|---|
| 109 |
# you need to have an account on this machine and sudo access |
|---|
| 110 |
# |
|---|
| 111 |
# This will install a rails stack on three hosts simultaneously |
|---|
| 112 |
# It should take about ten minutes depending on network and server speeds. |
|---|
| 113 |
# |
|---|
| 114 |
export HOSTS=r01,r02,r03 # define some hosts to mess with |
|---|
| 115 |
cap setup_ssh_keys # copy your public keys to the servers |
|---|
| 116 |
cap install_rails_stack # install apache, rubygems, mongrel, rails, etc. |
|---|
| 117 |
unset HOSTS # stop overriding cap's hosts list |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
## deploy a rails app to hosts |
|---|
| 121 |
# |
|---|
| 122 |
# setup dns for your domain or put an entry in /etc/hosts |
|---|
| 123 |
cd /path/to/app |
|---|
| 124 |
deprec --apply-to . |
|---|
| 125 |
# open config/deploy.rb to update :domain, :application and :repository fields |
|---|
| 126 |
cap setup |
|---|
| 127 |
cap deploy_with_migrations |
|---|
| 128 |
cap restart_apache |
|---|
| 129 |
|
|---|
| 130 |
# update rails app on hosts |
|---|
| 131 |
cap deploy |
|---|
| 132 |
cap deploy_with_migrations |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
## some handy tools |
|---|
| 136 |
# |
|---|
| 137 |
cap show_tasks |
|---|
| 138 |
cap disable_web, enable_web # puts up maintenance page |
|---|
| 139 |
cap restart_mongrel_cluster # does what it says |
|---|
| 140 |
|
|---|
| 141 |
|
|---|