Capistrano 使用了错误的发布路径
我现在尝试将我的应用程序部署到我的 ubuntu server-11.04(主机名:chicago),但是每次运行 cap deploy:update 时,我总是收到以下错误:
** [chicago :: out] push something
** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/images': No such file or directory
** [out :: chicago]
** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/stylesheets'
** [out :: chicago] : No such file or directory
** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/javascripts'
** [out :: chicago] : No such file or directory
** [out :: chicago] (in /var/deploy/ziya/releases/20120113085410)
** [out :: chicago] Could not find rake-0.9.2.2 in any of the sources
** [out :: chicago] Run `bundle install` to install missing gems.
*** [deploy:update_code] rolling back
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2@ziya' -c 'cd /var/deploy/ziya/releases/20120113085410 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on chicago
但是当我检查服务器时:没有发布:20120113085410
larry@chicago:/var/deploy/ziya/releases$ ls -l
total 16
drwxrwxr-x 17 larry larry 4096 Jan 6 14:28 20120106024740
drwxrwxr-x 19 larry larry 4096 Jan 12 21:39 20120112065325
drwxrwxr-x 17 larry larry 4096 Jan 13 15:24 20120113072414
drwxrwxr-x 17 larry larry 4096 Jan 13 15:26 20120113072621
以下是我的deploy.rb,
set :application, "ziya"
server "chicago", :app, :web, :db, :primary => true
# setup scm:
set :repository, "git@myhost:myuser/ziya.git"
set :deploy_via, :remote_cache
set :scm_username, "myuser"
set :scm, :git
set :scm_verbose, "true"
set :branch, "master"
set(:releases_path) { File.join(deploy_to, version_dir) }
set(:shared_path) { File.join(deploy_to, shared_dir) }
set(:current_path) { File.join(deploy_to, current_dir) }
set(:release_path) { File.join(releases_path, release_name) }
# ssh to the deploy server
default_run_options[:pty] = true
set :deploy_to, "/var/deploy/#{application}"
after 'deploy:update_code' do
run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
end
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
以下是我的Capfile:
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.2@ziya'
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
而且我还预计rvm配置有问题,因为我对该部分不太确定。
I am now trying to deploy my application to my ubuntu server-11.04(hostname: chicago), but every time I run cap deploy:update, I always get the following error:
** [chicago :: out] push something
** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/images': No such file or directory
** [out :: chicago]
** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/stylesheets'
** [out :: chicago] : No such file or directory
** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/javascripts'
** [out :: chicago] : No such file or directory
** [out :: chicago] (in /var/deploy/ziya/releases/20120113085410)
** [out :: chicago] Could not find rake-0.9.2.2 in any of the sources
** [out :: chicago] Run `bundle install` to install missing gems.
*** [deploy:update_code] rolling back
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2@ziya' -c 'cd /var/deploy/ziya/releases/20120113085410 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on chicago
But when I check on the server: there's no release: 20120113085410
larry@chicago:/var/deploy/ziya/releases$ ls -l
total 16
drwxrwxr-x 17 larry larry 4096 Jan 6 14:28 20120106024740
drwxrwxr-x 19 larry larry 4096 Jan 12 21:39 20120112065325
drwxrwxr-x 17 larry larry 4096 Jan 13 15:24 20120113072414
drwxrwxr-x 17 larry larry 4096 Jan 13 15:26 20120113072621
following is my deploy.rb,
set :application, "ziya"
server "chicago", :app, :web, :db, :primary => true
# setup scm:
set :repository, "git@myhost:myuser/ziya.git"
set :deploy_via, :remote_cache
set :scm_username, "myuser"
set :scm, :git
set :scm_verbose, "true"
set :branch, "master"
set(:releases_path) { File.join(deploy_to, version_dir) }
set(:shared_path) { File.join(deploy_to, shared_dir) }
set(:current_path) { File.join(deploy_to, current_dir) }
set(:release_path) { File.join(releases_path, release_name) }
# ssh to the deploy server
default_run_options[:pty] = true
set :deploy_to, "/var/deploy/#{application}"
after 'deploy:update_code' do
run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
end
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
and following is my Capfile:
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.2@ziya'
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
And I also expect that there something wrong for the rvm configurations, because I am not so sure about that part..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经编写了一个 afterhook 来预编译资产。您不必这样做,因为下面的行(您的代码中已经有)将为您执行此操作。
添加此行以在生产环境中捆绑 gem:
如果您仍然遇到 rake-not-found 错误的问题,请尝试使用
bundle exec rake
总结:
您需要首先捆绑安装并安装然后预编译资产。
顺便说一句,如果部署失败,回滚命令将删除该文件夹。这就是为什么您无法找到上述目录的原因。
You have written an after-hook to pre-compile the assets. You don't have to do that because the following line(which you already have in your code) will do that for you.
Add this line to bundle the gems in production environment:
If you still face the issue with rake-not-found error, try using
bundle exec rake
To summarize:
You need to first bundle-install & then pre-compile the assets.
By the way, the rollback command will remove the folder if the deployment fails. That is why you are not able to find the mentioned directory.