I could not figure out how to get streaming output in cap 4. For me, in Cap 3.4.0 with sshkit 1.11.1 execute did not do this.
But looking at sshkit docs, here is one way to crack it, which works:
class StreamOutputInteractionHandler def on_data(_command, stream_name, data, channel) $stderr.print data end end
This can be strange, especially if you are running on multiple hosts, this, of course, will alternate the output. You can use the capistrano log, similar to the way to create the built-in MappingInteractionHandler, but I wanted to print it directly to the console so that I could get partial output in front of new lines (progress bar from the rake task).
Discussion with sshkit helper. https://github.com/capistrano/sshkit/issues/395#issuecomment-288489866
source share