【问题标题】:Problems deploying with Capistrano (symlink error)Capistrano 部署问题(符号链接错误)
【发布时间】:2013-02-19 17:24:07
【问题描述】:

在尝试部署到我的登台服务器时,当 Capistrano 尝试创建 database.yml 文件时出现错误。

目前我的 gitIgnore 文件中有 database.yml 文件(我已经尝试将其包含在内)。

我以前从来没有遇到过这个问题,所以我真的不知道如何调试这个问题。

非常感谢任何帮助。

部署日志:

executing `deploy:symlink'
  * executing "rm -f /home/deploy/example.com/current && ln -s /home/deploy/example.com/releases/20130219164028 /home/deploy/example.com/current"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 1893ms
    triggering after callbacks for `deploy:symlink'
  * executing `deploy:copy_database_yml'
  * executing "ln -s /home/deploy/example.com/shared/data/development /home/deploy/example.com/releases/20130219164028/solr/data/live"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 1867ms
  * executing "ln -s /home/deploy/example.com/shared/config/database.yml /home/deploy/example.com/releases/20130219164028/config/database.yml"
    servers: ["example.com"]
    [example.com] executing command
 ** [out :: example.com] ln: creating symbolic link `/home/deploy/example.com/releases/20130219164028/config/database.yml'
 ** [out :: example.com] : File exists
    command finished in 2086ms
*** [deploy:symlink] rolling back
*** no previous release to rollback to, rollback of symlink skipped
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deploy/example.com/releases/20130219164028; true"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 2640ms
failed: "env PATH=/home/deploy/example.com/bin:$PATH GEM_HOME=/home/deploy/example.com/gems sh -c 'ln -s /home/deploy/example.com/shared/config/database.yml /home/deploy/example.com/releases/20130219164028/config/database.yml'" on example.com

我的 deploy.rb 文件的内容

set :stages, %w(staging integration live)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
require "bundler/capistrano"

default_run_options[:pty] = true

set :application, "Example"
set :use_sudo, false
set :keep_releases, 5

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
#set :people, 'root'
#set :ssh_options, { :forward_agent => true }

namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => {:no_release => true} do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do
      ;
    end
  end

  # Avoid keeping the database.yml configuration in git.
  desc "task to create a symlink for the database files."
  task :copy_database_yml do
    run "ln -s #{shared_path}/data/development #{release_path}/solr/data/live"
    run "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
    run "rm -rf #{release_path}/public/photos"
    run "ln -s #{shared_path}/public/photos #{release_path}/public/photos"
    run "rm -rf #{release_path}/public/hobby_photos"
    run "ln -s #{shared_path}/public/hobby_photos #{release_path}/public/hobby_photos"
    run "chmod 777 -R #{release_path}"
    #run "cd #{release_path}; bundle exec rake db:migrate RAILS_ENV=staging"
    #    run "cd #{release_path}/ & rake db:migrate RAILS_ENV=staging"
  end

end

after "deploy:symlink", "deploy:copy_database_yml"

【问题讨论】:

  • 看起来您正在使用一些自定义 capistrano 配方来处理 database.yml,请发布它们
  • 刚刚添加了我的 deploy.rb 文件的内容,希望对您有所帮助。

标签: ruby-on-rails deployment capistrano passenger


【解决方案1】:

看起来你的答案就在眼前。

** [out :: example.com] ln: creating symbolic link `/home/deploy/example.com/releases/20130219164028/config/database.yml'
** [out :: example.com] : File exists

修改您的 deploy:copy_database_yml 以首先删除符号链接,或者仅在它不存在时创建它。 顺便说一句,这个任务比它的名字暗示的要多得多,这很糟糕。

【讨论】:

    【解决方案2】:

    创建符号链接时似乎是 Capistrano 的问题。

    尝试在 deploy.rb 文件中注释角色:

    #role :app, %w{deploy@yourhost.com}
    #role :web, %w{deploy@yourhost.com}
    #role :db,  %w{deploy@yourhost.com}
    

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 1970-01-01
      • 2010-10-13
      • 1970-01-01
      • 2021-04-08
      • 2016-02-09
      • 2014-07-07
      • 2014-05-30
      相关资源
      最近更新 更多