Sha256: 9dc18da24bec220e43eb68695a56411c6efee03299cd6c2640fe03d11bd08429

Contents?: true

Size: 1.45 KB

Versions: 20

Compression:

Stored size: 1.45 KB

Contents

class FluentdController < ApplicationController
  before_action :find_fluentd, only: [:show, :edit, :update, :destroy, :log, :raw_log, :errors]
  before_action :check_fluentd_exists, only: [:edit, :log, :raw_log, :errors]

  def show
  end

  def new
    @fluentd = Fluentd.new(variant: params[:variant] || "fluentd")
    @fluentd.load_settings_from_agent_default
  end

  def create
    @fluentd = Fluentd.new(fluentd_params)
    unless @fluentd.save
      return render :new
    end
    redirect_to daemon_path
  end

  def edit
  end

  def update
    # TODO: should restart if changed file path? or just do "dirty" flagged?
    @fluentd.update_attributes(fluentd_params)
    unless @fluentd.save
      return render :edit
    end
    redirect_to daemon_path
  end
  
  def destroy
    @fluentd.agent.stop if @fluentd.agent.running?
    @fluentd.destroy
    redirect_to root_path, flash: {success: t('messages.destroy_succeed_fluentd_setting', brand: fluentd_ui_brand)}
  end

  def log
  end

  def errors
    @error_duration_days = 5
    @errors = @fluentd.agent.errors_since(@error_duration_days.days.ago)
  end

  def raw_log
    send_data @fluentd.agent.log, type: "application/octet-stream", filename: File.basename(@fluentd.log_file)
  end

  private

  def fluentd_params
    params.require(:fluentd).permit(:log_file, :pid_file, :config_file, :variant, :api_endpoint)
  end

  def check_fluentd_exists
    unless fluentd_exists?
      redirect_to root_path
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
fluentd-ui-0.3.14 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.13 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.12 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.11 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.10 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.9 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.8 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.7 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.6 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.5 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.3 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.2 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.1 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.0 app/controllers/fluentd_controller.rb
fluentd-ui-0.2.0 app/controllers/fluentd_controller.rb
fluentd-ui-0.1.4 app/controllers/fluentd_controller.rb
fluentd-ui-0.1.3 app/controllers/fluentd_controller.rb
fluentd-ui-0.1.2 app/controllers/fluentd_controller.rb
fluentd-ui-0.1.1 app/controllers/fluentd_controller.rb
fluentd-ui-0.1.0 app/controllers/fluentd_controller.rb