Project

General

Profile

« Previous | Next » 

Revision 5f7fd34c

Added by Lukas Zapletal over 8 years ago

Fixes #11318 - HttpDownloads.start_download returns instance

instead of `true`. Allows to join processes, useful for discovery image
plugin.

View differences:

lib/proxy/util.rb
module Proxy::Util
class CommandTask
include Proxy::Log
attr_reader :command
# create new task and spawn new thread logging all the cmd
# output to the proxy log. only the process' output is connected
# stderr is redirected to proxy error log, stdout to proxy debug log
def initialize(acommand, &blk)
def initialize(acommand)
@command = acommand
end
def start(&ensured_block)
# run the task in its own thread
logger.debug "Starting task: #{acommand}"
@task = Thread.new(acommand) do |cmd|
logger.debug "Starting task: #{@command}"
@task = Thread.new(@command) do |cmd|
begin
status = nil
Open3::popen3(cmd) do |stdin,stdout,stderr,thr|
......
yield if block_given?
end
end
self
end
# wait for the task to finish and get the subprocess return code

Also available in: Unified diff