2013-02-19 77 views
1

當試圖部署到我的登臺服務器時,當Capistrano試圖創建database.yml文件時,我看到一個錯誤。用Capistrano部署的問題(符號鏈接錯誤)

目前我在我的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" 
+0

看起來你正在使用一些自定義Capistrano的食譜處理database.yml的,請把它們 – cthulhu 2013-02-19 17:41:39

+0

只是加了我deploy.rb的內容文件,希望它有幫助。 – 2013-02-19 17:45:14

回答

3

它看起來像你的答案就在你的眼前。

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

修改您的部署:copy_database_yml先刪除符號鏈接,或者只有當它不存在,創建它。 順便說一句,這個任務的作用遠不止它的名字,這是不好的。

0

這似乎是創建符號鏈接時的Capistrano問題。

試評在deploy.rb文件中的角色:

​​