Sha256: ab960bb1dad2d7362a560e0494d20b4bcfc1ff4294ea9aa0ab072a60fe59b12b
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
require_relative "io_monitor" require_relative "boot_message" class ProconBypassMan::Runner class InterruptForRestart < StandardError; end include ProconBypassMan::SignalHandler def initialize(gadget: , procon: ) @gadget = gadget @procon = procon ProconBypassMan::PrintBootMessageCommand.execute end def run self_read, self_write = IO.pipe %w(TERM INT USR1 USR2).each do |sig| begin trap sig do self_write.puts(sig) end rescue ArgumentError ProconBypassMan::SendErrorCommand.execute(error: "Signal #{sig} not supported") end end loop do $will_terminate_token = false # TODO forkしないでThreadでいいのでは? main_loop_pid = Kernel.fork { ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute } begin while(readable_io = IO.select([self_read])) signal = readable_io.first[0].gets.strip handle_signal(signal) end rescue InterruptForRestart $will_terminate_token = true Process.kill("TERM", main_loop_pid) Process.wait ProconBypassMan.logger.info("Reloading config file") begin ProconBypassMan::ButtonsSettingConfiguration::Loader.reload_setting ProconBypassMan::SendReloadConfigEventCommand.execute rescue ProconBypassMan::CouldNotLoadConfigError ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。再読み込みができませんでした") end ProconBypassMan.logger.info("バイパス処理を再開します") rescue Interrupt $will_terminate_token = true Process.kill("TERM", main_loop_pid) Process.wait @gadget&.close @procon&.close FileUtils.rm_rf(ProconBypassMan.pid_path) FileUtils.rm_rf(ProconBypassMan.digest_path) exit 1 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
procon_bypass_man-0.1.14 | lib/procon_bypass_man/runner.rb |
procon_bypass_man-0.1.13 | lib/procon_bypass_man/runner.rb |