Sha256: ada70aaa79a6b9f4636c6f7127f4ff724fe33402385e18bb05860e6de00c45e8

Contents?: true

Size: 1.46 KB

Versions: 18

Compression:

Stored size: 1.46 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.log.errors_since(@error_duration_days.days.ago)
  end

  def raw_log
    send_data @fluentd.agent.log.read, 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

18 entries across 18 versions & 1 rubygems

Version Path
fluentd-ui-1.0.0 app/controllers/fluentd_controller.rb
fluentd-ui-1.0.0.beta.1 app/controllers/fluentd_controller.rb
fluentd-ui-1.0.0.alpha.3 app/controllers/fluentd_controller.rb
fluentd-ui-1.0.0.alpha.2 app/controllers/fluentd_controller.rb
fluentd-ui-1.0.0.alpha.1 app/controllers/fluentd_controller.rb
fluentd-ui-0.4.5 app/controllers/fluentd_controller.rb
fluentd-ui-0.4.4 app/controllers/fluentd_controller.rb
fluentd-ui-0.4.3 app/controllers/fluentd_controller.rb
fluentd-ui-0.4.2 app/controllers/fluentd_controller.rb
fluentd-ui-0.4.1 app/controllers/fluentd_controller.rb
fluentd-ui-0.4.0 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.21 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.20 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.19 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.18 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.17 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.16 app/controllers/fluentd_controller.rb
fluentd-ui-0.3.15 app/controllers/fluentd_controller.rb