Capistrano 3进程失败

时间:2014-02-11 03:38:08

标签: ruby-on-rails ruby-on-rails-3 capistrano capistrano3

我正在从Capistrano 2升级到Capistrano 3,一切似乎都在成功运行,除非我看到这两个在运行时失败:

DEBUG [bbfe01ec] Running /usr/bin/env [ -L /var/www/myapp/releases/20140211033611/public/assets ] on myapp.com
DEBUG [bbfe01ec] Command: [ -L /var/www/myapp/releases/20140211033611/public/assets ]
DEBUG [bbfe01ec] Finished in 0.146 seconds with exit status 1 (failed).
DEBUG [26f99b11] Running /usr/bin/env [ -d /var/www/myapp/releases/20140211033611/public/assets ] on myapp.com
DEBUG [26f99b11] Command: [ -d /var/www/myapp/releases/20140211033611/public/assets ]
DEBUG [26f99b11] Finished in 0.141 seconds with exit status 1 (failed).

为什么这些失败了,我该如何解决?

1 个答案:

答案 0 :(得分:2)

我有同样的问题,这里是capistrano代码,当你收到这些错误时实现:

desc 'Symlink linked directories'
  task :linked_dirs do
    next unless any? :linked_dirs
    on release_roles :all do
      execute :mkdir, '-pv', linked_dir_parents(release_path)

      fetch(:linked_dirs).each do |dir|
        target = release_path.join(dir)
        source = shared_path.join(dir)
        unless test "[ -L #{target} ]"
          if test "[ -d #{target} ]"
            execute :rm, '-rf', target
          end
          execute :ln, '-s', source, target
        end
      end
    end
  end

我可以理解这里使用命令ln来创建符号链接。

阅读关于ln(man ln)的手册,我们理解,当尝试制作硬链接目录时,该命令可能会因系统限制而失败。

-d, -F, --directory
  allow the superuser to attempt to hard link directories (note: will probably fail 
  due to system restrictions, even for the superuser)

'ln -d'无法创建硬链接,这就是执行'ln -s'以创建符号链接(符号链接而不是硬链接)的原因。

所以,不用担心这会失败。如果您想避免它,只需更改您的部署选项:

set :format, :pretty
set :log_level, :info