mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-04 18:36:13 +02:00
Refactor updating fluentd-ui
This commit is contained in:
parent
959c2b2bc1
commit
b10171b89a
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user