Refactor updating fluentd-ui

This commit is contained in:
uu59 2014-07-07 10:52:11 +09:00
parent 959c2b2bc1
commit b10171b89a
2 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,8 @@
require "fluent/version"
class MiscController < ApplicationController
after_action :update!, only: [:update_fluentd_ui]
def show
redirect_to misc_information_path
end
@ -11,7 +13,6 @@ class MiscController < ApplicationController
end
def update_fluentd_ui
FluentdUiRestart.new.async.perform
@current_pid = $$
render "update_fluentd_ui", layout: "sign_in"
end
@ -29,4 +30,10 @@ class MiscController < ApplicationController
render text: "finished"
end
end
private
def update!
FluentdUiRestart.new.async.perform
end
end

View File

@ -4,8 +4,12 @@ class FluentdUiRestart
LOCK = []
def lock!
raise "update process is still running" if LOCK.present?
LOCK << true
raise "update process is still running" if locked?
LOCK << true # dummy value
end
def locked?
LOCK.present?
end
def unlock!
@ -14,7 +18,6 @@ class FluentdUiRestart
def perform
lock!
sleep 5 # delay for render updating HTML
# NOTE: install will be failed before released fluentd-ui gem
SuckerPunch.logger.info "[restart] install new fluentd-ui"