Class: Fluentd::AgentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/fluentd/agents_controller.rb

Instance Method Summary collapse

Instance Method Details

#log_tailObject



31
32
33
34
# File 'app/controllers/fluentd/agents_controller.rb', line 31

def log_tail
  @logs = @fluentd.agent.log_tail(params[:limit]).reverse if @fluentd
  render json: @logs
end

#restartObject



22
23
24
25
26
27
28
29
# File 'app/controllers/fluentd/agents_controller.rb', line 22

def restart
  if @fluentd.agent.restart
    flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.restart'))
  else
    flash[:error] = t("messages.fluentd_restart_failed", brand: fluentd_ui_title) + @fluentd.agent.log_tail(1).first
  end
  redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
end

#startObject



4
5
6
7
8
9
10
11
# File 'app/controllers/fluentd/agents_controller.rb', line 4

def start
  if @fluentd.agent.start
    flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.start'))
  else
    flash[:error] = t("messages.fluentd_start_failed", brand: fluentd_ui_title) + @fluentd.agent.log_tail(1).first
  end
  redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
end

#stopObject



13
14
15
16
17
18
19
20
# File 'app/controllers/fluentd/agents_controller.rb', line 13

def stop
  if @fluentd.agent.stop
    flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.stop'))
  else
    flash[:error] = t("messages.fluentd_stop_failed", brand: fluentd_ui_title)
  end
  redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
end