Class: ProconBypassMan::RemoteActionReceiver

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/remote_action/remote_action_receiver.rb

Overview

FIXME: BypassProcessSenderみたいにする

Class Method Summary collapse

Class Method Details

.receive(task) ⇒ Object



29
30
31
32
33
# File 'lib/procon_bypass_man/remote_action/remote_action_receiver.rb', line 29

def self.receive(task)
  ProconBypassMan.logger.info "[remote macro][receiver] name: #{task.name}, uuid: #{task.uuid}, steps: #{task.steps}, type: #{task.type}"
  ProconBypassMan::RemoteAction::TaskQueueInProcess.push(task)
  true
end

.runObject



18
19
20
21
22
23
24
25
# File 'lib/procon_bypass_man/remote_action/remote_action_receiver.rb', line 18

def self.run
  while(task = ProconBypassMan::RemoteAction::QueueOverProcess.pop)
    receive(task)
  end
  shutdown
rescue Errno::ENOENT, Errno::ECONNRESET, Errno::ECONNREFUSED => e
  ProconBypassMan.logger.debug(e)
end

.shutdownObject



35
36
37
# File 'lib/procon_bypass_man/remote_action/remote_action_receiver.rb', line 35

def self.shutdown
  ProconBypassMan.logger.info("ProconBypassMan::RemoteMacroReceiverを終了します。")
end

.start!Object



10
11
12
13
14
15
16
# File 'lib/procon_bypass_man/remote_action/remote_action_receiver.rb', line 10

def self.start!
  return unless ProconBypassMan.config.enable_remote_action?

  Thread.start do
    start_with_foreground!
  end
end

.start_with_foreground!Object

forkしたプロセスで動かすクラス。sock経由で命令を受け取ってmacoのキューに積んでいく



4
5
6
7
8
# File 'lib/procon_bypass_man/remote_action/remote_action_receiver.rb', line 4

def self.start_with_foreground!
  return unless ProconBypassMan.config.enable_remote_action?

  run
end