module ProconBypassMan

Constants

VERSION

Public Class Methods

configure(setting_path: nil, &block) click to toggle source
# File lib/procon_bypass_man.rb, line 23
def self.configure(setting_path: nil, &block)
  unless setting_path
    logger.warn "setting_pathが未設定です。設定ファイルのライブリロードが使えません。"
  end

  if block_given?
    ProconBypassMan::Configuration.instance.instance_eval(&block)
  else
    ProconBypassMan::Configuration::Loader.load(setting_path: setting_path)
  end
end
digest_path() click to toggle source
# File lib/procon_bypass_man.rb, line 91
def self.digest_path
  "#{root}/.setting_yaml_digest"
end
logger() click to toggle source
# File lib/procon_bypass_man.rb, line 59
def self.logger
  if defined?(@@logger)
    @@logger
  else
    Logger.new(nil)
  end
end
logger=(logger) click to toggle source
# File lib/procon_bypass_man.rb, line 55
def self.logger=(logger)
  @@logger = logger
end
pid_path() click to toggle source
# File lib/procon_bypass_man.rb, line 67
def self.pid_path
  @@pid_path ||= File.expand_path("#{root}/pbm_pid", __dir__).freeze
end
reset!() click to toggle source
# File lib/procon_bypass_man.rb, line 71
def self.reset!
  ProconBypassMan::Procon::MacroRegistry.reset!
  ProconBypassMan::Procon::ModeRegistry.reset!
  ProconBypassMan::Procon.reset!
  ProconBypassMan::Configuration.instance.reset!
  ProconBypassMan::IOMonitor.reset!
end
root() click to toggle source
# File lib/procon_bypass_man.rb, line 79
def self.root
  if defined?(@@root)
    @@root
  else
    File.expand_path('..', __dir__).freeze
  end
end
root=(path) click to toggle source
# File lib/procon_bypass_man.rb, line 87
def self.root=(path)
  @@root = path
end
run(setting_path: nil, &block) click to toggle source
# File lib/procon_bypass_man.rb, line 35
def self.run(setting_path: nil, &block)
  configure(setting_path: setting_path, &block)
  File.write(pid_path, $$)
  Runner.new.run
rescue CouldNotLoadConfigError
  ProconBypassMan.logger.error "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
  puts "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
  FileUtils.rm_rf(ProconBypassMan.pid_path)
  FileUtils.rm_rf(ProconBypassMan.digest_path)
  exit 1
rescue EternalConnectionError
  ProconBypassMan.logger.error "接続の見込みがないのでsleepしまくります"
  puts "接続の見込みがないのでsleepしまくります"
  FileUtils.rm_rf(ProconBypassMan.pid_path)
  sleep(999999999)
rescue FirstConnectionError
  puts "接続を確立できませんでした。やりなおします。"
  retry
end