Google Groups Home
Help | Sign in
buffering output per line
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Stephen Haberman  
View profile
 More options Oct 27 2006, 1:49 pm
From: Stephen Haberman <step...@exigencecorp.com>
Date: Fri, 27 Oct 2006 12:49:56 -0500
Local: Fri, Oct 27 2006 1:49 pm
Subject: buffering output per line
Hi,

I have not been using capistrano for a whole lot just yet, but for
executing the few remote commands I've been doing, I've found buffering
the return output per line to be a lot easier to read:

    # Buffer capistrano output per line
    Capistrano::Actor.default_io_proc = Proc.new do |ch, stream, out|
      ch[stream] ||= ''
      ch[stream] << out
      if out[-1..-1] == "\n"
        level = stream == :err ? :important : :info
        ch[:actor].logger.send(level, ch[stream], "#{stream} :: #{ch[:host]}")
        ch[stream] = ''
      end
    end

I must admit its been a few weeks since I wrote this, but as I recall it
turned the output I was seeing from:

    out :: host1 Restarting daemon
    out :: host1 [OK]
    out :: host1 ...
    out :: host2 Restarting daemon
    out :: host2 [OK]
    out :: host2 ...

To just:

    out :: host1 Restarting daemon [OK]
    out :: host2 Restarting daemon [OK]

I would almost suggest this as a patch, but just because its desirable
for my situation, I don't know if its desirable for all situations.

- Stephen


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jamis Buck  
View profile
 More options Nov 1 2006, 12:50 pm
From: Jamis Buck <ja...@37signals.com>
Date: Wed, 1 Nov 2006 10:50:12 -0700
Local: Wed, Nov 1 2006 12:50 pm
Subject: Re: [Capistrano] buffering output per line

Stephen,

I've considered this, but I don't want this behavior in general. For  
instance, consider the long-running process that emits some progress  
indicator character, like a '.', each time some increment of the  
operation finishes. A newline may not be emitted for many minutes,  
but you'd like to see some progress being made.

For an action that you know will not behave like that, though, it  
might be a nice option to specify that you want line buffering.  
Perhaps as an option to run:

   run "some command", :buffer => true do |ch, stream, out|
     ...
   end

Thoughts?

- Jamis

On Oct 27, 2006, at 11:49 AM, Stephen Haberman wrote:

  smime.p7s
3K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Haberman  
View profile
 More options Nov 1 2006, 4:41 pm
From: Stephen Haberman <step...@exigencecorp.com>
Date: Wed, 1 Nov 2006 15:41:21 -0600
Local: Wed, Nov 1 2006 4:41 pm
Subject: Re: [Capistrano] Re: buffering output per line

On Wed, 1 Nov 2006 10:50:12 -0700

Jamis Buck <ja...@37signals.com> wrote:
> I've considered this, but I don't want this behavior in general. For
> instance, consider the long-running process that emits some progress
> indicator character, like a '.', each time some increment of the
> operation finishes. A newline may not be emitted for many minutes,
> but you'd like to see some progress being made.

Good point. That's the sort of use case I was thinking of but could not
articulate.

> For an action that you know will not behave like that, though, it
> might be a nice option to specify that you want line buffering.
> Perhaps as an option to run:

>    run "some command", :buffer => true do |ch, stream, out|
>      ...
>    end

I like that. But instead of :buffer, perhaps :per_line_output. Or
something like that.

I've attached a patch--but haven't actually tried it yet. Later today
I'll likely be using capistrano to deploy some stuff and will try it out
then.

- Stephen

  capistrano-per_line_output.diff
1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google