mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-12 01:07:09 +02:00
54 lines
1.4 KiB
Ruby
54 lines
1.4 KiB
Ruby
class Fluentd::SettingsController < ApplicationController
|
|
before_action :login_required
|
|
before_action :find_fluentd
|
|
|
|
def show
|
|
@config = File.read(@fluentd.agent.config_file) # TODO
|
|
end
|
|
|
|
def edit
|
|
@config = File.read(@fluentd.agent.config_file) # TODO
|
|
end
|
|
|
|
def update
|
|
File.open(@fluentd.agent.config_file, "w") do |f| # TODO: should update by agent class
|
|
f.write params[:config]
|
|
end
|
|
@fluentd.agent.restart if @fluentd.agent.running?
|
|
redirect_to fluentd_setting_path(@fluentd)
|
|
end
|
|
|
|
def in_tail_after_file_choose
|
|
@setting = Fluentd::Setting::InTail.new({
|
|
:path => params[:path],
|
|
:tag => nil,
|
|
})
|
|
end
|
|
|
|
def in_tail_confirm
|
|
@setting = Fluentd::Setting::InTail.new(setting_params)
|
|
unless @setting.valid?
|
|
return render "in_tail_after_file_choose"
|
|
end
|
|
end
|
|
|
|
def in_tail_finish
|
|
@setting = Fluentd::Setting::InTail.new(setting_params)
|
|
unless @setting.valid?
|
|
return render "in_tail_after_file_choose"
|
|
end
|
|
File.open(@fluentd.agent.config_file, "a") do |f| # TODO: should update by agent class
|
|
f.write "\n"
|
|
f.write @setting.to_conf
|
|
end
|
|
@fluentd.agent.restart if @fluentd.agent.running?
|
|
redirect_to fluentd_setting_path(@fluentd)
|
|
end
|
|
|
|
private
|
|
|
|
def setting_params
|
|
params.require(:setting).permit(:path, :tag, :rotate_wait, :pos_file, :read_from_head, :refresh_interval)
|
|
end
|
|
end
|