capistrano 3部署RoR应用程序错误:ln:无法创建符号链接:文件存在

时间:2014-09-29 09:03:04

标签: ruby-on-rails deployment capistrano3

我正在尝试使用Capistrano 3进行部署,但失败了。

它返回了这样一个错误:

** Invoke deploy:symlink:shared (first_time) ** Execute deploy:symlink:shared ** Invoke deploy:symlink:linked_files (first_time) ** Execute deploy:symlink:linked_files ** Invoke deploy:symlink:linked_dirs (first_time) ** Execute deploy:symlink:linked_dirs INFO[8051297e] Running /usr/bin/env mkdir -pv /home/wango/apps/wango/releases/20140929084104/public on 101.227.244.212 INFO[b6759259] Running /usr/bin/env mkdir -pv /home/wango/apps/wango/releases/20140929084104/public on wango.cc INFO[8051297e] Finished in 0.024 seconds with exit status 0 (successful). INFO[b6759259] Finished in 0.025 seconds with exit status 0 (successful). INFO[871fe15d] Running /usr/bin/env ln -s /home/wango/apps/wango/shared/public/assets /home/wango/apps/wango/releases/20140929084104/public/assets on 101.227.244.212 INFO[bca7add7] Running /usr/bin/env ln -s /home/wango/apps/wango/shared/public/assets /home/wango/apps/wango/releases/20140929084104/public/assets on wango.cc INFO[871fe15d] Finished in 0.023 seconds with exit status 0 (successful). cap aborted! SSHKit::Runner::ExecuteError: Exception while executing on host wango.cc: ln exit status: 1 ln stdout: Nothing written ln stderr: ln: failed to create symbolic link ‘/home/wango/apps/wango/releases/20140929084104/public/assets/assets’: File exists

在我的版本文件夹中,有多个“资产”文件夹:

/释放/ 20140929084104 /公共/资产/资产

我该如何解决?

这是我的deploy.rb:

# config valid only for Capistrano 3.1
lock '3.2.1'

set :application, 'wango'
set :repo_url, 'git@bitbucket.org:jofone/wango.git'
set :branch, 'master'

set :user, 'wango'
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :scm, :git

set :format, :pretty
set :log_level, :info
set :pty, true

# set :linked_files, %w{config/database.yml config/app_config.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

set :keep_releases, 5

namespace :deploy do

  desc "Check that we can access everything"
    task :check_write_permissions do
      on roles(:all) do |host|
        if test("[ -w #{fetch(:deploy_to)} ]")
          info "#{fetch(:deploy_to)} is writable on #{host}"
        else
          error "#{fetch(:deploy_to)} is not writable on #{host}"
        end
      end
    end

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      sudo "service #{fetch(:application)}_server restart"
      sudo "service nginx restart"
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

# namespace :assets do
#   before :backup_manifest, 'deploy:assets:create_manifest_json'
#   task :create_manifest_json do
#     on roles :web do
#       within release_path do
#         execute :mkdir, release_path.join('assets_manifest_backup')
#       end
#     end
#   end
# end

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 16]
set :puma_workers, 0
set :puma_init_active_record, true
set :puma_preload_app, true

0 个答案:

没有答案