New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for config.command_output #7
Conversation
Sample output:
|
One problem I see is that in a multi-server deployment, the output from different servers could be mixed together and hard to distinguish. The However, it is probably only an issue for long-running commands… not sure if it is worth complicating the output. |
Hi @mattbrictson, everything looks good to me. Regarding multi-server deployment you might be right, right now I don't have any multi deployment where I can test it. But I guess that in such case the developer can switch between I was testing the branch and I found out something strange. Can't tell who is guilty... I have this simple task: namespace :logs do
desc 'Tailf production logs'
task :tail do
on roles(:app) do
Airbrussh.configuration.command_output = true if defined?(Airbrussh)
execute :tail, '-f', release_path.join('log', "#{fetch(:rails_env, 'production')}.log")
end
end
end And for same reason, the first 10 lines (the one coming from the existing files) will be separated by and empty line (a |
@carlesso Good catch. I think the problem was that |
The problem is that if airbrussh/lib/airbrussh/formatter.rb Line 141 in 73704b2
next if output.empty?
# to
next if output.chomp.empty? Or here airbrussh/lib/airbrussh/formatter.rb Line 144 in 73704b2
print_line " #{number} #{line.chomp}"
# to
print_line " #{number} #{line.chomp}" unless line.chomp.empty? Maybe the latter is better. |
Is that a problem, though? What if the You're saying that there are situations where I think this option is safer, since it less likely to skip legitimate blank lines: next if output.chomp.empty? |
I'm not sure where the line is coming for (or how #!/usr/bin/env ruby
require 'sshkit/dsl'
require 'airbrussh'
SSHKit.config.output = Airbrussh::Formatter.new($stdout)
Airbrussh.configuration.command_output = true
run_locally do
execute 'tail', '-f', 'path/to/my.log'
end And it is working fine. Maybe there is something strange going on with lograge that I'm using in that project. And you are totally right, if |
Great! I'll merge this and release 0.3.0 today. Thanks for your help. 🙌 |
Thank you! |
Normally airbrussh hides all stderr and stdout data returned by SSH commands. With this commit, users of airbrussh can selectively enable displaying of stderr and/or stdout data.
192c02d
to
42a16ff
Compare
Normally airbrussh hides all stderr and stdout data returned by SSH commands. With this commit, users of airbrussh can selectively enable displaying of stderr and/or stdout data.
Addesses #3
@carlesso can you review?