27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Deploy away!<br />

The next line after this makes these folders group writable with the chmod<br />

command:<br />

chmod g+w /home/ticketeeapp.com/apps/ticketee<br />

/home/ticketeeapp.com/apps/ticketee/releases<br />

/home/ticketeeapp.com/apps/ticketee/shared<br />

/home/ticketeeapp.com/apps/ticketee/shared/system<br />

/home/ticketeeapp.com/apps/ticketee/shared/log<br />

/home/ticketeeapp.com/apps/ticketee/shared/pids<br />

At the bottom of this command’s output you can see what servers it will be executed<br />

on, with only your one server listed for now. It also tells you that the command is being<br />

executed and, faster than you can blink, that the command has finished. chmod isn’t<br />

an intensive operation:<br />

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

[your-server] executing command<br />

command finished<br />

Once the deploy:setup Capistrano task has finished, you are returned to a console<br />

prompt. Now you can put the application on the server by deploying it!<br />

14.5.4 Deploying the application<br />

Capistrano has now been configured to deploy the Ticketee application and you’ve<br />

set up your server using the cap deploy:setup command, leaving it up to you now to<br />

deploy your code. Capistrano’s deploy task will let you do this, and you can run this<br />

task with this command:<br />

cap deploy<br />

This command outputs an even larger output to cap deploy:setup, but again we’ll go<br />

through it line by line. It’s not all that intimidating when it’s broken down into little<br />

chunks, really! The first output you’ll see from a deploy is<br />

* executing `deploy'<br />

* executing `deploy:update'<br />

** transaction: start<br />

* executing `deploy:update_code'<br />

These first three lines tell you the tasks which are being executed. The deploy task is<br />

going to be executed because you asked Capistrano to do that. This task depends on<br />

the deploy:update task, and so it will run that first.<br />

The deploy:update task begins a transaction (the third line in the output), which<br />

is exceptionally helpful. If anything goes wrong in your deploy, Capistrano will roll<br />

back everything to the beginning of this transaction, deleting any code it’s deployed.<br />

This transaction is a failsafe for your deploy.<br />

The final part of the output is the deploy:update_code task, which is responsible<br />

for updating the application’s code in your deployment environment. This task is<br />

responsible for the next chunk of output you see:<br />

401

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

Saved successfully!

Ooh no, something went wrong!