简体   繁体   中英

Capistrano 3 with symlinks

I have been 3 days trying to deploy my app (Ruby on Rails 4) with Capistrano 3, but I really couldn't find an answer.

I got an error in console that says:

ln: creating symbolic link «/home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml»: El fichero ya existe
    cap aborted!
    ln stdout: Nothing written
    ln stderr: Nothing written

"El fichero ya existe" is a sentence that means: " the file already exists"

This is my deploy.rb:

set :application, 'eatsy'
set :repo_url, 'https://github.com/conexionweb/eatsy.git'
set :branch, "rails"

set :deploy_to, '/home/miguelnieva/webapps/eatsy/'
set :scm, :git
set :branch, "rails"

set :use_sudo, false

set :rails_env, "production"

set :pty, true

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

# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :keep_releases, 1

set :deploy_via, :remote_cache

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

after :finishing, 'deploy:cleanup'

end

This is the complete log:

$ cap deploy production --trace

....

** Invoke deploy:symlink:shared (first_time)
** Execute deploy:symlink:shared
** Invoke deploy:symlink:linked_files (first_time)
** Execute deploy:symlink:linked_files
 INFO [804288b4] Running /usr/bin/env mkdir -pv /home/miguelnieva/webapps/eatsy/releases/20140124005756/config on web396.webfaction.com
DEBUG [804288b4] Command: /usr/bin/env mkdir -pv /home/miguelnieva/webapps/eatsy/releases/20140124005756/config
 INFO [9232a3e0] Running /usr/bin/env mkdir -pv /home/miguelnieva/webapps/eatsy/releases/20140124005756/config on 108.168.242.146
DEBUG [9232a3e0] Command: /usr/bin/env mkdir -pv /home/miguelnieva/webapps/eatsy/releases/20140124005756/config
 INFO [9232a3e0] Finished in 0.198 seconds with exit status 0 (successful).
DEBUG [8fd8907c] Running /usr/bin/env [ -L /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ] on 108.168.242.146
DEBUG [8fd8907c] Command: [ -L /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ]
 INFO [804288b4] Finished in 0.201 seconds with exit status 0 (successful).
DEBUG [9d8736a7] Running /usr/bin/env [ -L /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ] on web396.webfaction.com
DEBUG [9d8736a7] Command: [ -L /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ]
DEBUG [8fd8907c] Finished in 0.190 seconds with exit status 1 (failed).
DEBUG [22b4e01b] Running /usr/bin/env [ -f /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ] on 108.168.242.146
DEBUG [22b4e01b] Command: [ -f /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ]
DEBUG [9d8736a7] Finished in 0.206 seconds with exit status 1 (failed).
DEBUG [b46bc068] Running /usr/bin/env [ -f /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ] on web396.webfaction.com
DEBUG [b46bc068] Command: [ -f /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml ]
DEBUG [22b4e01b] Finished in 0.175 seconds with exit status 1 (failed).
 INFO [e75127e8] Running /usr/bin/env ln -s /home/miguelnieva/webapps/eatsy/shared/config/database.yml /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml on 108.168.242.146
DEBUG [e75127e8] Command: /usr/bin/env ln -s /home/miguelnieva/webapps/eatsy/shared/config/database.yml /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml
DEBUG [b46bc068] Finished in 0.180 seconds with exit status 1 (failed).
 INFO [1a838606] Running /usr/bin/env ln -s /home/miguelnieva/webapps/eatsy/shared/config/database.yml /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml on web396.webfaction.com
DEBUG [1a838606] Command: /usr/bin/env ln -s /home/miguelnieva/webapps/eatsy/shared/config/database.yml /home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml
 INFO [e75127e8] Finished in 0.171 seconds with exit status 0 (successful).
DEBUG [1a838606]    ln: creating symbolic link «/home/miguelnieva/webapps/eatsy/releases/20140124005756/config/database.yml»: El fichero ya existe
cap aborted!
ln stdout: Nothing written
ln stderr: Nothing written
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-3.1.0/lib/capistrano/tasks/deploy.rake:126:in `block (5 levels) in <top (required)>'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-3.1.0/lib/capistrano/tasks/deploy.rake:119:in `each'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-3.1.0/lib/capistrano/tasks/deploy.rake:119:in `block (4 levels) in <top (required)>'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/miguelnieva/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:symlink:linked_files
The deploy has failed with an error: #<SSHKit::Command::Failed: ln stdout: Nothing written
ln stderr: Nothing written
>
** Invoke deploy:failed (first_time)
** Execute deploy:failed

I am not sure if capistrano is copying the files twice.

Thank you!

Check this answer: Capistrano can not create symlinks: file exist

In deploy/production.rb:

role :app, %w{ubuntu@api01.app.com}
role :web, %w{ubuntu@api01.app.com}
role :db,  %w{ubuntu@api01.app.com}

... needs to match:

server 'api01.app.com', user: 'ubuntu', roles: %w{web app}, ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM