Cool beans
On Feb 16, 2013 10:16 AM, "John Russell" <notifications@github.com> wrote:

> In lib/sensu/client.rb:
>
> > @@ -74,6 +74,30 @@ def publish_result(check)
> >        @amq.queue('results').publish(payload.to_json)
> >      end
> >
> > +    # if the command is a ruby script it is around 20 times faster to fork the client
> > +    # process than to sh -c ruby the script and it doesn't spike the CPU nearly as much
> > +    def execute_with_ruby_fork(command)
> > +      @logger.debug('attempting to execute command in ruby fork', {
> > +        :command => command
> > +      })
> > +      # IO.popen does not run at_exit handlers which is what sensu-plugins use to run scripts
> > +      # So we have to do the output capture manually.
> > +      rd, wr = ::IO.pipe
> > +      child_pid = ::Kernel.fork do
> > +        rd.close
>
> I didn't need STDIN to work and I saw this in the example of IO.pipe
> http://www.ruby-doc.org/core-1.9.3/IO.html#method-c-pipe. My guess is its
> just belt and suspenders since this process is going to live all of 40ms.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/Tapjoy/sensu/pull/18/files#r3039469>.
>
>