Sha256: 81587bb6e7ee23504fecb90f39d5cd0bdf9e3d7dff13ed9113a0963820232900

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 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::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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.11 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb