27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

servers: ["your-server"]<br />

[your-server] executing command<br />

command finished<br />

Deploy away!<br />

The second-to-last step for the deploy:update task is to run the deploy:symlink task,<br />

which symbolically links the new release directory to the current folder within your<br />

deploy path (in this example, /home/ticketeeapp.com/apps/ticketee/current):<br />

* executing `deploy:symlink'<br />

* executing "rm -f [current_path] &&<br />

ln -s [release_path] [current_path]<br />

servers: ["your-server"]<br />

[your-server] executing command<br />

command finished<br />

The last action of the deploy:update task is to commit the transaction that began at<br />

the start, meaning your deploy was successful:<br />

** transaction: commit<br />

The absolutely final thing the deploy task does is call deploy:restart, which will touch<br />

the tmp/restart file in your new application directory (/home/ticketeeapp.com/<br />

apps/ticketee/current), which would restart the server if you had one running:<br />

* executing `deploy:restart'<br />

* executing "touch [current_path]/tmp/restart.txt"<br />

servers: ["your-server"]<br />

[your-server] executing command<br />

command finished<br />

And that’s it! Your application is deployed for the first time; however, it’s not quite<br />

ready for prime-time usage. For starters, the application’s gems are not installed! On<br />

your development box you will do this by running the bundle install task, but you’re<br />

no longer in Kansas 24 or on your own development box for that matter. Bundler has<br />

some pretty slick integration with Capistrano, which will run bundle install when<br />

you deploy. This functionality is provided to you by a file that comes with the gem.<br />

14.5.5 Bundling gems<br />

You can trigger the bundle install task to happen (in a slightly different fashion<br />

than usual) when you do a deploy by requiring the bundler/capistrano file in the config/deploy.rb<br />

of your application, right at the top:<br />

require 'bundler/capistrano'<br />

You’ll also need to require RVM’s capistrano configuration so that when you do a<br />

deploy it can locate the bundle command (provided by a gem that was installed using<br />

an RVM-provided Ruby install), which it will need to run bundle install. At the top<br />

of config/deploy.rb, put these lines:<br />

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))<br />

require 'rvm/capistrano'<br />

24 Apologies for any Kansas-based readers out there. Let me assure you, you are still (most likely) in Kansas.<br />

403

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!