I have uploaded a app in production mode to linode.
I want make changes in local app in css, javascript, controllers, models, or any file that I need change or update code and after deploy in my remote app.
I use capistrano, and I have this recipe in deploy.rb file.
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load pathe
require "rvm/capistrano" # Load RVM's capistrano plugin.
require "bundler/capistrano"
set :rvm_ruby_string, 'ruby-1.9.2-p318@global'
set :rvm_type, :user
set :application, "app.com"
set :user, 'myuser'
set :repository, "#{user}@ip.ip.ip.ip:~/app"
ssh_options[:forward_agent] = true
set :scm, :git
set :use_sudo, false
set :keep_releases, 1
set :deploy_to, "~/#{application}"
#set :deploy_via, :copy
set :deploy_via, :remote_cache
role :web, "ip.ip.ip.ip" # Your HTTP server, Apache/etc
role :app, "ip.ip.ip.ip" # This may be the same as your `Web` server
role :db, "ip.ip.ip.ip", :primary => true # This is where Rails migrations will run
load 'deploy/assets'
The problem is that when I run cap deploy the process is very very slow take a 5 or 6 minutes in deploy If I want change 2 files or add a gem I want update only those files that have changed.
How can I speed up the deploy with capistrano. With git I go very fast but I have that enter more command, git add . git commit…
Note**
I have check with set :deploy_via, :remote_cache but I get errors with permissions in log of capistrano :O.
Log capistrano after cap deploy
[ip.ip.ip.ip] executing command
[ip.ip.ip.ip] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.2-p318@global' -c 'if [ -d ~/app.com/shared/cached-copy ]; then cd ~/app.com/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e142768dc6351878cb45712dca8d31ead4ffb40c && git clean -q -d -x -f; else git clone -q myuser@ip.ip.ip.ip:~/app ~/app.com/shared/cached-copy && cd ~/app.com/shared/cached-copy && git checkout -q -b deploy e142768dc6351878cb45712dca8d31ead4ffb40c; fi'
** [ip.ip.ip.ip :: err] Permission denied, please try again.
** [ip.ip.ip.ip :: err] Permission denied, please try again.
** [ip.ip.ip.ip :: err] Permission denied (publickey,password).
** [ip.ip.ip.ip :: err] fatal: The remote end hung up unexpectedly
command finished in 1337ms
*** [deploy:update_code] rolling back
* executing "rm -rf ~/app.com/releases/20120325150641; true"
servers: ["ip.ip.ip.ip"]
[ip.ip.ip.ip] executing command
[ip.ip.ip.ip] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.2-p318@global' -c 'rm -rf ~/app.com/releases/20120325150641; true'
command finished in 702ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.2-p318@global' -c 'if [ -d ~/app.com/shared/cached-copy ]; then cd ~/app.com/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e142768dc6351878cb45712dca8d31ead4ffb40c && git clean -q -d -x -f; else git clone -q myuser@ip.ip.ip.ip:~/app ~/app.com/shared/cached-copy && cd ~/app.com/shared/cached-copy && git checkout -q -b deploy e142768dc6351878cb45712dca8d31ead4ffb40c; fi'" on 109.74.195.41
After create cached-copy directory
myuser@myuser:~/app.com/current$ if [ -d ~/app.com/shared/cached-copy ];
> then cd ~/app.com/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e142768dc6351878cb45712dca8d31ead4ffb40c && git clean -q -d -x -f; else git clone -q myuser@ip.ip.ip.ip:~/app ~/app.com/shared/cached-copy && cd ~/app.com/shared/cached-copy && git checkout -q -b deploy e142768dc6351878cb45712dca8d31ead4ffb40c; fi
myuser@ip.ip.ip.ip's password:
myuser@ip.ip.ip.ip:~/app.com/shared/cached-copy$
Thank you very much!
The first thing I would suggest to speed it up is getting the deploy_via :remote_cache working. You need to make sure that the remote user can authenticate to your git repo, which means configuring your SSH key on the remote server to connect.
Try setting this:
Github has a great help article on getting it working:
http://help.github.com/deploy-with-capistrano/