Sha256: 8d79143a304a2fa6edec302f785c72310afe41c8f398ea2bbb30f07d1a5a462a

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

class ProconBypassMan::RemoteMacroReceiver
  # forkしたプロセスで動かすクラス。sock経由で命令を受け取ってmacoのキューに積んでいく
  def self.start_with_foreground!
    return unless ProconBypassMan.config.enable_remote_macro?

    run
  end

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

    Thread.start do
      start_with_foreground!
    end
  end

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


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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
procon_bypass_man-0.2.2 lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb
procon_bypass_man-0.1.23 lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb
procon_bypass_man-0.1.22 lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb