Capistrano 使用了错误的发布路径

发布于 2024-12-26 07:54:22 字数 3169 浏览 1 评论 0原文

我现在尝试将我的应用程序部署到我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晒暮凉 2025-01-02 07:54:22

您已经编写了一个 afterhook 来预编译资产。您不必这样做,因为下面的行(您的代码中已经有)将为您执行此操作。

load 'deploy/assets'

添加此行以在生产环境中捆绑 gem:

require "bundler/capistrano"

如果您仍然遇到 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.

load 'deploy/assets'

Add this line to bundle the gems in production environment:

require "bundler/capistrano"

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文