【问题标题】:capistrano command is failing silently without any feedbackcapistrano 命令在没有任何反馈的情况下静默失败
【发布时间】:2010-01-06 16:30:58
【问题描述】:

我正在尝试创建一个 capistrano 任务来设置我的日志轮换文件。

namespace :app do
  task :setup_log_rotation,:roles => :app do
    rotate_script = %Q{#{shared_path}/log/#{stage}.log {
      daily
      rotate #{ENV['days'] || 7}
      size #{ENV['size'] || "5M"}
      compress
      create 640 #{user} #{ENV['group'] || user}
      missingok
    }}

    put rotate_script, "#{shared_path}/logrotate_script"

    "sudo cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}"

    run "rm #{shared_path}/logrotate_script"
  end
end

在 deploy.rb 文件的最顶部,我有以下行

set :use_sudo, false

我完全错过了我的 cp 命令默默地失败了,在我的终端上我认为一切都很好。这是不好的。我应该如何编写 cp 代码,以防 cp 由于某种原因失败(在这种情况下 sudo 命令失败),然后我应该在终端上获得反馈。

【问题讨论】:

    标签: capistrano


    【解决方案1】:

    解决了我自己的问题。

    查看this 是否有类似内容。

    我在 deploy.rb 中添加这一行

    default_run_options[:pty] = true
    

    run "sudo cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}"
    

    到这里

    sudo "cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      • 2020-06-12
      • 1970-01-01
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多