Module: AcpcTableManager::Opponents

Extended by:
SimpleLogging
Defined in:
lib/acpc_table_manager/opponents.rb

Class Method Summary collapse

Methods included from SimpleLogging

log, log_with, logger

Class Method Details

.start(*bot_start_commands) ⇒ Array<Integer>

Returns PIDs of the opponents started.

Returns:

  • (Array<Integer>)

    PIDs of the opponents started



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/acpc_table_manager/opponents.rb', line 13

def self.start(*bot_start_commands)
  @logger ||= ::AcpcTableManager.new_log 'opponents.log'
  log __method__, num_opponents: bot_start_commands.length

  bot_start_commands.map do |bot_start_command|
    log(
      __method__,
      {
        bot_start_command_parameters: bot_start_command,
        command_to_be_run: bot_start_command.join(' ')
      }
    )
    pid = Timeout::timeout(3) do
      ProcessRunner.go(bot_start_command)
    end
    log(
      __method__,
      {
        bot_started?: true,
        pid: pid
      }
    )
    pid
  end
end