mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-12 01:07:09 +02:00
34 lines
1004 B
Ruby
34 lines
1004 B
Ruby
class Fluentd::AgentsController < ApplicationController
|
|
before_action :find_fluentd
|
|
|
|
def start
|
|
run_action(__method__) { @fluentd.agent.log_tail(1).first }
|
|
redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
|
|
end
|
|
|
|
def stop
|
|
run_action(__method__)
|
|
redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
|
|
end
|
|
|
|
def restart
|
|
run_action(__method__) { @fluentd.agent.log_tail(1).first }
|
|
redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
|
|
end
|
|
|
|
def log_tail
|
|
@logs = @fluentd.agent.log_tail(params[:limit]).reverse if @fluentd
|
|
render json: @logs
|
|
end
|
|
|
|
private
|
|
def run_action(action)
|
|
if @fluentd.agent.public_send(action)
|
|
flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t("fluentd.common.#{action}"))
|
|
else
|
|
flash[:error] = t("messages.fluentd_#{action}_failed", brand: fluentd_ui_title)
|
|
flash[:error] += yield if block_given?
|
|
end
|
|
end
|
|
end
|