Capistrano V3在database.yml上失败

时间:2022-06-05 18:24:59

I am using the latest version of Capistrano w/ my Rails 4 application. When running cap dpeloy. I get a lot of output including this failure:

我正在使用最新版本的Capistrano w / my Rails 4应用程序。运行cap dpeloy时。我得到了很多输出,包括这个失败:

DEBUG [04b6e226] Running /usr/bin/env [ -f /var/www/skateboxes/releases/20131022135522/config/database.yml ] on 162.243.33.179
DEBUG [04b6e226] Command: [ -f /var/www/skateboxes/releases/20131022135522/config/database.yml ]
DEBUG [04b6e226] Finished in 0.280 seconds with exit status 1 (failed).

How do I figure out what is going on here?

我如何弄清楚这里发生了什么?

Update #1

I should say that I have gitignored config/database.yml (as was suggested by the capistrano docs). I then added the following to my config/deploy.rb

我应该说我有gitignored config / database.yml(正如capistrano docs所建议的那样)。然后我将以下内容添加到我的config / deploy.rb中

set :linked_files, %w{config/database.yml}

I then created a file on my VPS at /var/www/skateboxes/shared/config/database.yml.

然后我在我的VPS上创建了一个文件/var/www/skateboxes/shared/config/database.yml。

Am I not understanding how linked_files works?

我不明白linked_files是如何工作的?

Update #2

It turns out that the file is actually being linked from shared/conf/database.yml to current/config/database.yml so now I'm confused as to why it's saying failed

事实证明该文件实际上是从shared / conf / database.yml链接到current / config / database.yml所以现在我很困惑为什么它说失败了

Update #3

Here is the entire output of my deploy

这是我部署的整个输出

DEBUG Uploading /tmp/git-ssh.sh 0.0%
 INFO Uploading /tmp/git-ssh.sh 100.0%
 INFO [37fffef8] Running /usr/bin/env chmod +x /tmp/git-ssh.sh on 162.243.33.179
DEBUG [37fffef8] Command: ( RAILS_ENV=production /usr/bin/env chmod +x /tmp/git-ssh.sh )
 INFO [37fffef8] Finished in 0.282 seconds with exit status 0 (successful).
DEBUG [d8542e52] Running /usr/bin/env git ls-remote git@github.com:kyledecot/skateboxes.git on 162.243.33.179
DEBUG [d8542e52] Command: ( RAILS_ENV=production GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:kyledecot/skateboxes.git )
DEBUG [d8542e52] Finished in 1.448 seconds with exit status 0 (successful).
DEBUG [d8542e52]    e0f96188b9567a84048a0e1238f219abc6351607    HEAD
DEBUG [d8542e52]    e0f96188b9567a84048a0e1238f219abc6351607    refs/heads/master
DEBUG [d8542e52] Finished in 1.448 seconds with exit status 0 (successful).
 INFO [5a13328b] Running /usr/bin/env mkdir -pv /var/www/skateboxes/shared /var/www/skateboxes/releases on 162.243.33.179
DEBUG [5a13328b] Command: ( RAILS_ENV=production /usr/bin/env mkdir -pv /var/www/skateboxes/shared /var/www/skateboxes/releases )
 INFO [5a13328b] Finished in 0.719 seconds with exit status 0 (successful).
 INFO [293e065b] Running /usr/bin/env mkdir -pv /var/www/skateboxes/shared/config on 162.243.33.179
DEBUG [293e065b] Command: ( RAILS_ENV=production /usr/bin/env mkdir -pv /var/www/skateboxes/shared/config )
 INFO [293e065b] Finished in 0.780 seconds with exit status 0 (successful).
DEBUG [4eb81576] Running /usr/bin/env [ -f /var/www/skateboxes/shared/config/database.yml ] on 162.243.33.179
DEBUG [4eb81576] Command: [ -f /var/www/skateboxes/shared/config/database.yml ]
DEBUG [4eb81576] Finished in 0.744 seconds with exit status 0 (successful).
DEBUG [89a9e1fa] Running /usr/bin/env [ -f /var/www/skateboxes/repo/HEAD ] on 162.243.33.179
DEBUG [89a9e1fa] Command: [ -f /var/www/skateboxes/repo/HEAD ]
DEBUG [89a9e1fa] Finished in 0.734 seconds with exit status 0 (successful).
 INFO The repository mirror is at /var/www/skateboxes/repo
DEBUG [3cc4d694] Running /usr/bin/env if test ! -d /var/www/skateboxes/repo; then echo "Directory does not exist '/var/www/skateboxes/repo'" 1>&2; false; fi on 162.243.33.179
DEBUG [3cc4d694] Command: if test ! -d /var/www/skateboxes/repo; then echo "Directory does not exist '/var/www/skateboxes/repo'" 1>&2; false; fi
DEBUG [3cc4d694] Finished in 0.735 seconds with exit status 0 (successful).
 INFO [1cb24a84] Running /usr/bin/env git remote update on 162.243.33.179
DEBUG [1cb24a84] Command: cd /var/www/skateboxes/repo && ( RAILS_ENV=production /usr/bin/env git remote update )
DEBUG [1cb24a84]    Fetching origin
DEBUG [1cb24a84]    remote: Counting objects: 5, done.
remote: Compressing objects: 100% (1/1), done.
DEBUG [1cb24a84]    remote: Total 3 (delta 2), reused 3 (delta 2)
DEBUG [1cb24a84]    Unpacking objects:  33% (1/3)
DEBUG [1cb24a84]    Unpacking objects:  66% (2/3)
Unpacking objects: 100% (3/3), done.jects: 100% (3/3)
DEBUG [1cb24a84]    From github.com:kyledecot/skateboxes
DEBUG [1cb24a84]       de7f4a1..e0f9618  master     -> master
 INFO [1cb24a84] Finished in 0.817 seconds with exit status 0 (successful).
DEBUG [edd6c793] Running /usr/bin/env if test ! -d /var/www/skateboxes/repo; then echo "Directory does not exist '/var/www/skateboxes/repo'" 1>&2; false; fi on 162.243.33.179
DEBUG [edd6c793] Command: if test ! -d /var/www/skateboxes/repo; then echo "Directory does not exist '/var/www/skateboxes/repo'" 1>&2; false; fi
DEBUG [edd6c793] Finished in 0.732 seconds with exit status 0 (successful).
 INFO [009b81fe] Running /usr/bin/env mkdir -p /var/www/skateboxes/releases/20131022145520 on 162.243.33.179
DEBUG [009b81fe] Command: cd /var/www/skateboxes/repo && ( RAILS_ENV=production GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env mkdir -p /var/www/skateboxes/releases/20131022145520 )
 INFO [009b81fe] Finished in 0.317 seconds with exit status 0 (successful).
 INFO [e9554374] Running /usr/bin/env git archive master | tar -x -C /var/www/skateboxes/releases/20131022145520 on 162.243.33.179
DEBUG [e9554374] Command: cd /var/www/skateboxes/repo && ( RAILS_ENV=production GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git archive master | tar -x -C /var/www/skateboxes/releases/20131022145520 )
 INFO [e9554374] Finished in 0.356 seconds with exit status 0 (successful).
 INFO [165a7c40] Running /usr/bin/env mkdir -pv /var/www/skateboxes/releases/20131022145520/config on 162.243.33.179
DEBUG [165a7c40] Command: ( RAILS_ENV=production /usr/bin/env mkdir -pv /var/www/skateboxes/releases/20131022145520/config )
 INFO [165a7c40] Finished in 1.174 seconds with exit status 0 (successful).
DEBUG [c2f7de66] Running /usr/bin/env [ -L /var/www/skateboxes/releases/20131022145520/config/database.yml ] on 162.243.33.179
DEBUG [c2f7de66] Command: [ -L /var/www/skateboxes/releases/20131022145520/config/database.yml ]
DEBUG [c2f7de66] Finished in 0.572 seconds with exit status 1 (failed).
DEBUG [09de2f2c] Running /usr/bin/env [ -f /var/www/skateboxes/releases/20131022145520/config/database.yml ] on 162.243.33.179
DEBUG [09de2f2c] Command: [ -f /var/www/skateboxes/releases/20131022145520/config/database.yml ]
DEBUG [09de2f2c] Finished in 0.304 seconds with exit status 1 (failed).
 INFO [05570e6e] Running /usr/bin/env ln -s /var/www/skateboxes/shared/config/database.yml /var/www/skateboxes/releases/20131022145520/config/database.yml on 162.243.33.179
DEBUG [05570e6e] Command: ( RAILS_ENV=production /usr/bin/env ln -s /var/www/skateboxes/shared/config/database.yml /var/www/skateboxes/releases/20131022145520/config/database.yml )
 INFO [05570e6e] Finished in 0.541 seconds with exit status 0 (successful).
 INFO [8499b753] Running /usr/bin/env rm -rf /var/www/skateboxes/current on 162.243.33.179
DEBUG [8499b753] Command: ( RAILS_ENV=production /usr/bin/env rm -rf /var/www/skateboxes/current )
 INFO [8499b753] Finished in 0.762 seconds with exit status 0 (successful).
 INFO [bddc6793] Running /usr/bin/env ln -s /var/www/skateboxes/releases/20131022145520 /var/www/skateboxes/current on 162.243.33.179
DEBUG [bddc6793] Command: ( RAILS_ENV=production /usr/bin/env ln -s /var/www/skateboxes/releases/20131022145520 /var/www/skateboxes/current )
 INFO [bddc6793] Finished in 0.289 seconds with exit status 0 (successful).
DEBUG [38a6b176] Running /usr/bin/env ls -x /var/www/skateboxes/releases on 162.243.33.179
DEBUG [38a6b176] Command: ( RAILS_ENV=production /usr/bin/env ls -x /var/www/skateboxes/releases )
DEBUG [38a6b176] Finished in 0.741 seconds with exit status 0 (successful).
DEBUG [38a6b176]    20131022133912  20131022133939  20131022134435  20131022135522  20131022145350
DEBUG [38a6b176]    20131022145520
DEBUG [38a6b176] Finished in 0.741 seconds with exit status 0 (successful).
 INFO Keeping 5 of 6 deployed releases on 162.243.33.179
 INFO [7da6047f] Running /usr/bin/env rm -rf /var/www/skateboxes/releases/20131022133912 on 162.243.33.179
DEBUG [7da6047f] Command: ( RAILS_ENV=production /usr/bin/env rm -rf /var/www/skateboxes/releases/20131022133912 )
 INFO [7da6047f] Finished in 0.530 seconds with exit status 0 (successful).
DEBUG [7cdd5da9] Running /usr/bin/env if test ! -d /var/www/skateboxes/releases; then echo "Directory does not exist '/var/www/skateboxes/releases'" 1>&2; false; fi on 162.243.33.179
DEBUG [7cdd5da9] Command: if test ! -d /var/www/skateboxes/releases; then echo "Directory does not exist '/var/www/skateboxes/releases'" 1>&2; false; fi
DEBUG [7cdd5da9] Finished in 0.727 seconds with exit status 0 (successful).
 INFO [906548e8] Running /usr/bin/env echo "Branch master deployed as release 20131022145520 by kyledecot; " >> /var/www/skateboxes/revisions.log on 162.243.33.179
DEBUG [906548e8] Command: echo "Branch master deployed as release 20131022145520 by kyledecot; " >> /var/www/skateboxes/revisions.log
 INFO [906548e8] Finished in 0.279 seconds with exit status 0 (successful).

1 个解决方案

#1


5  

That's not a failure, see https://github.com/leehambley/sshkit/pull/33.

这不是失败,请参阅https://github.com/leehambley/sshkit/pull/33。

It says failed because that is not a file, thus the test command ([ aka man (1) test) has exited with status 1.

它表示失败,因为它不是文件,因此测试命令([aka man(1)test)已退出状态1。

The command in question is coming out of this code, reproduced below:

有问题的命令来自此代码,转载如下:

desc 'Symlink linked files'
task :linked_files do
  next unless any? :linked_files
  on roles :app do
    execute :mkdir, '-pv', linked_file_dirs(release_path)

    fetch(:linked_files).each do |file|
      target = release_path.join(file)
      source = shared_path.join(file)
      unless test "[ -L #{target} ]"
        if test "[ -f #{target} ]"
          execute :rm, target
        end
        execute :ln, '-s', source, target
      end
    end
  end
end
desc 'Check files to be linked exist in shared'
task :linked_files do
  next unless any? :linked_files
  on roles :app do |host|
    linked_files(shared_path).each do |file|
      unless test "[ -f #{file} ]"
        error t(:linked_file_does_not_exist, file: file, host: host)
        exit 1
      end
    end
  end
end

The task name says it all, really, if your file is listed in the :linked_files variable, it must exist in shared_path, otherwise it will cause Capistrano to abort when the file does not exist.

任务名称说明了一切,实际上,如果您的文件列在:linked_files变量中,它必须存在于shared_pa​​th中,否则当文件不存在时,它将导致Capistrano中止。

You haven't yet said whether or not this is causing your deploy to fail, and since you've posted so little of the log, indicating nothing but normal behaviour, nobody can guess.

你还没有说过这是否会导致你的部署失败,而且由于你发布了这么少的日志,只表示正常的行为,没有人能猜到。

You appear to be posting logs from the Symlink linked files task, which is supposed to fail on config/database.yml if it doesn't exist, it has failed to find it, so it does not have to be deleted.

您似乎是从Symlink链接文件任务发布日志,该任务应该在config / database.yml上失败,如果它不存在,则无法找到它,因此不必删除它。

#1


5  

That's not a failure, see https://github.com/leehambley/sshkit/pull/33.

这不是失败,请参阅https://github.com/leehambley/sshkit/pull/33。

It says failed because that is not a file, thus the test command ([ aka man (1) test) has exited with status 1.

它表示失败,因为它不是文件,因此测试命令([aka man(1)test)已退出状态1。

The command in question is coming out of this code, reproduced below:

有问题的命令来自此代码,转载如下:

desc 'Symlink linked files'
task :linked_files do
  next unless any? :linked_files
  on roles :app do
    execute :mkdir, '-pv', linked_file_dirs(release_path)

    fetch(:linked_files).each do |file|
      target = release_path.join(file)
      source = shared_path.join(file)
      unless test "[ -L #{target} ]"
        if test "[ -f #{target} ]"
          execute :rm, target
        end
        execute :ln, '-s', source, target
      end
    end
  end
end
desc 'Check files to be linked exist in shared'
task :linked_files do
  next unless any? :linked_files
  on roles :app do |host|
    linked_files(shared_path).each do |file|
      unless test "[ -f #{file} ]"
        error t(:linked_file_does_not_exist, file: file, host: host)
        exit 1
      end
    end
  end
end

The task name says it all, really, if your file is listed in the :linked_files variable, it must exist in shared_path, otherwise it will cause Capistrano to abort when the file does not exist.

任务名称说明了一切,实际上,如果您的文件列在:linked_files变量中,它必须存在于shared_pa​​th中,否则当文件不存在时,它将导致Capistrano中止。

You haven't yet said whether or not this is causing your deploy to fail, and since you've posted so little of the log, indicating nothing but normal behaviour, nobody can guess.

你还没有说过这是否会导致你的部署失败,而且由于你发布了这么少的日志,只表示正常的行为,没有人能猜到。

You appear to be posting logs from the Symlink linked files task, which is supposed to fail on config/database.yml if it doesn't exist, it has failed to find it, so it does not have to be deleted.

您似乎是从Symlink链接文件任务发布日志,该任务应该在config / database.yml上失败,如果它不存在,则无法找到它,因此不必删除它。