class Redmine::Commands::Start

Attributes

arguments[R]
config[R]

Public Class Methods

new(arguments, config) click to toggle source
# File lib/redmine/commands/start.rb, line 16
def initialize(arguments, config)
  @arguments = arguments
  @config    = config
end

Public Instance Methods

execute() click to toggle source
# File lib/redmine/commands/start.rb, line 21
def execute
  run_command Redmine::Commands::Docker::Build.new(config).command_line
  run_command Redmine::Commands::Docker::CreateVolume.new(config).command_line
  run_command Redmine::Commands::Docker::Create.new(config, arguments).command_line
  run_command Redmine::Commands::Docker::CopyConfig.new(config).command_line
  run_command Redmine::Commands::Docker::Start.new(config).command_line
end

Private Instance Methods

run_command(command_line) click to toggle source
# File lib/redmine/commands/start.rb, line 31
def run_command(command_line)
  Open3.popen3(command_line) do |input, output, error, process_thread|
    Thread.new {
      until input.closed?
        inp = gets.chomp
        puts inp
        input.puts inp
      end
    }

    t_err = Thread.new do
      putc error.readchar until error.eof?
    end

    t_out = Thread.new {
      until output.eof?
        putc output.readchar
      end
    }

    begin
      Process.waitpid(process_thread.pid)
    rescue StandardError
      nil
    end

    t_err.join
    t_out.join
  end
end