Sha256: 233c681095964275ef941cc6fb172d18fef920f93fe774179ffffdf275cc900a

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module ProconBypassMan
  module RemoteAction
    module RemotePbmJob
      class RestorePbmSettingAction < BaseAction

        def action_content(args: )
          require "pbmenv"
          ProconBypassMan.logger.info "execute RestorePbmSettingAction!"
          setting = args.dig("setting") or raise(ProconBypassMan::RemotePbmJob::NeedPbmVersionError, "settingが必要です, #{args.inspect}")

          # 復元に失敗したら戻せるように退避する
          FileUtils.copy(
            ProconBypassMan.buttons_setting_configuration.setting_path,
            ProconBypassMan.fallback_setting_path,
          )

          ProconBypassMan::YamlWriter.write(
            path: ProconBypassMan.buttons_setting_configuration.setting_path,
            content: setting,
          )

          hot_reload!
        end

        private

        def before_action_callback
          be_in_progress
        end

        def after_action_callback
          be_processed
        end

        # @return [void]
        def hot_reload!
          Process.kill(:USR2, ProconBypassMan.pid)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb