views:

70

answers:

2

Hi all,

In response to this blog post: http://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/

I have three questions:

  1. Can anyone confirm if the recipe there works?
  2. Where and how do I put that recipe?
  3. I have two folders need to stay across each revisions: /products and /public/images/site_images what recipe should I run to be able to achieve this?

I have near zero experience with Capistrano and all I have been able to do so far was just cap deploy and cap deploy:cold, so a script which I could just copy-paste would be greatly appreciated.

Thank you

+2  A: 
  1. Yes, I'm currently using it in my own projects.

  2. You can just append the code at the end of your deploy.rb file

  3. If products is outside the public folder, you can't link it from the public side. Also, public/images is already expected to be checked into your SCM repository

The recipe assumes you want to have a complete new folder available from public side to host the user uploaded documents. The folder should be excluded from your SCM configuration to prevent accidental commits. You should avoid to use the public/images folder for external uploaded files or you will have many headaches trying to synchronize your development configuration, managed by a SCM, with the public state.

Simone Carletti
Hi, thank you for replying to this (and wow! from the writer of that post himself).For #3:I am aware it cannot be linked from public side, it is in fact needed to be that way. My question is what do I need to change on the recipe to allow two folders? Do I just change it to: task :symlink, :except => { :no_release => true } do run "rm -rf #{release_path}/public/images" run "ln -nfs #{shared_path}/images #{release_path}/public/images" run "rm -rf #{release_path}/products" run "ln -nfs #{shared_path}/products #{release_path}/products" endThank you!
jaycode
Hi again, this doesn't work, it removed the folders but does nothing beyond that. Anything I may did it wrong?
jaycode
A: 

This is how I did it in the end, by manual approach

I hope this will help all the early coders out there:

1. cd to releases to find out folder to synchronize
cd /home/yourapp/rails_apps/main/releases/

2. find the folder to sync, one level above last folder shown with ls
REMEMBER!
With ls, the folder list goes as follows:
folder1    folder5
folder2    folder6
folder3    folder7
folder4    folder8

So in this case, copy from folder7

3. copy the folders
To copy images
rsync -av --stats --progress /home/yourapp/rails_apps/main/releases/20100517183232/public/images/ /home/yourapp/rails_apps/main/current/public/images/

To copy products
rsync -av --stats --progress /home/yourapp/rails_apps/main/releases/20100517183232/products/ /home/yourapp/rails_apps/main/current/products/

Wondering if they could be automated somehow?

jaycode