Sha256: 05c37f037dc7434db23ffa4aed740ced2386700386f46f75f9e5f428a4cfa57a

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

module ProconBypassMan
  module RemotePbmAction
    class RestorePbmSettingAction < BaseAction

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

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

        ProconBypassMan::YamlWriter.write(
          path: ProconBypassMan::ButtonsSettingConfiguration.instance.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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.5 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb