Can I Stream the output with Capistrano 3 while the remote command is still running

499 views
Skip to first unread message

Robert Kuzelj

unread,
Apr 16, 2014, 4:58:24 AM4/16/14
to capis...@googlegroups.com

Hi,

I'd like to stream the same way as I could do with Capistrano2

task :memory do 
     run "free | awk '/^Mem:/{print $4}'" do | channel, stream, data |
          puts "host: #{channel[:host]} has free memory of #{data.to_i/1024} MB"
     end
end

Using capture wont help as it only prints after the remote command has finished.

The reason being that sometimes you have long running tasks that gives feedback to the user which I'd like to stream back to the control machine.

I tried to get my way through SSHKit and the Command class but I really can not find any place where the output stream from the remote server is handled.

It would be really cool if we could give an additional closure to execute and capture that receives the stream.

Any pointers are welcome

thx

ciao robertj

ps: feel free to answer this question on SO (http://stackoverflow.com/questions/23102980/can-i-stream-the-output-with-capistrano-3-while-the-remote-command-is-still-runn)

Lee Hambley

unread,
Apr 16, 2014, 5:57:59 AM4/16/14
to capistrano
Not merged, because I don't like the proposed API: https://github.com/capistrano/sshkit/pull/86

You might try that chap's branch of SSHKit, and report your findings to that issue.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/e8a56f32-e951-42da-94b1-8770cc673aab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Kuzelj

unread,
Apr 17, 2014, 8:35:51 AM4/17/14
to capis...@googlegroups.com
hmm, I actually dont understand the changes (and the API) proposed.
I think something close to the old API would be better

capture("some command") do | stream |
   #do somethign with stream here
end

I will have a closer look your code and maybe I could come up with a PR similar to what I wrote above.

ciao robertj
Reply all
Reply to author
Forward
0 new messages