我现在正在尝试将我的应用程序部署到我的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配置有问题,因为我对这部分不太确定..
答案 0 :(得分:1)
您已编写了一个后挂钩来预编译资产。您不必这样做,因为以下行(您已在代码中已有)将为您执行此操作。
load 'deploy/assets'
添加此行以捆绑生产环境中的gem:
require "bundler/capistrano"
如果您仍然遇到rake-not-found错误的问题,请尝试使用bundle exec rake
总结一下: 你需要先捆绑安装&然后预编译资产。
顺便说一句,如果部署失败,rollback命令将删除该文件夹。这就是为什么你找不到上面提到的目录。