代码之家  ›  专栏  ›  技术社区  ›  Roger

Capistrano命令在没有任何反馈的情况下自动失败

  •  0
  • Roger  · 技术社区  · 16 年前

    我试图创建一个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命令失败)而失败时,我应该在终端上得到反馈。

    1 回复  |  直到 16 年前
        1
  •  0
  •   Community Mohan Dere    8 年前

    解决了我自己的问题。

    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}"
    
    推荐文章