【问题标题】:Capistrano first deploy doens't work due to missing development.log file由于缺少 development.log 文件,Capistrano 首次部署不起作用
【发布时间】:2012-03-23 12:47:09
【问题描述】:

我想第一次使用带有 capistrano 2.8.0 的 Rails 3.2.1 部署网站。

当涉及到“rake db:migrate”时,进程被中止:

* executing `deploy:migrate'
* executing "cd /home/user/public_html/website.com/releases/20120323114534 && bundle exec rake RAILS_ENV=production  db:migrate"
servers: ["23.11.63.203"]
[23.11.63.203] executing command
** [out :: 23.11.63.203] rake aborted!
** [out :: 23.11.63.203] No such file or directory - /home/user/public_html/website.com/releases/20120323114534/log/production.log

我正在通过 github 进行部署,这是我的 deploy.rb 的相关部分:

require 'bundler/capistrano'
require 'whenever/capistrano'
set :rails_env, 'production'
set :application, "website.com"
set :domain, "website.com"
set :user, "user"
set :sudo_use, false
set :repository, "git@github.com:User/website.com.git"
set :local_repository,  '~/rails_projects/website.com/.git'
set :deploy_to, "/home/user/public_html/#{application}"
set :scm, :git
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true

server "23.11.63.203", :app, :web, :db, :primary => true

after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"
after "deploy:update_code", "deploy:migrate"

namespace :deploy do

  task :bundle_gems do
     run "cd #{deploy_to}/current && bundle install vendor/gems"
  end

  ...(there are some more tasks, but I think they cannot be relevant)

end

我在 deploy.rb 中尝试了以下操作,但没有成功,因此可能是解决此问题的错误方法:

after "deploy", "deploy:create_production_log"
namespace :deploy do

  desc "Creates the production log if it does not exist"
  task :create_production_log do
    unless File.exist?(File.join(shared_path, 'log', 'production.log'))
      puts "\n\n=== Creating Production Log! ===\n\n"
      run "touch #{File.join(shared_path, 'log', 'production.log')}"
    end
  end

end

在这种情况下,我如何进行第一次部署?

【问题讨论】:

    标签: ruby-on-rails-3 capistrano


    【解决方案1】:

    您是否执行了cap deploy:setup 并且cap deploy:check 是否告诉您一切正常?

    否则,我会说这是因为log 目录不存在,可能是因为您没有将它置于版本控制之下

    【讨论】:

    • 谢谢,这让我走上了正轨。在 cap deploy:setup 和 cap:deploy:check (没问题)之后,现在错误有点不同了(权限被拒绝 - /home/user/public_html/website.com/releases/20120323132001/log/production.log)。这很容易用 chown 解决...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    相关资源
    最近更新 更多