Resolve some TODOs

This commit is contained in:
uu59 2014-07-01 11:19:15 +09:00
parent bd1134f9a9
commit a3d61c3cc8
4 changed files with 22 additions and 15 deletions

View File

@ -38,10 +38,7 @@ class Fluentd::Settings::InTailController < ApplicationController
return render "after_format" return render "after_format"
end end
File.open(@fluentd.agent.config_file, "a") do |f| # TODO: should update by agent class @fluentd.agent.config_append @setting.to_conf
f.write "\n"
f.write @setting.to_conf
end
@fluentd.agent.restart if @fluentd.agent.running? @fluentd.agent.restart if @fluentd.agent.running?
redirect_to fluentd_setting_path(@fluentd) redirect_to fluentd_setting_path(@fluentd)
end end

View File

@ -3,17 +3,15 @@ class Fluentd::SettingsController < ApplicationController
before_action :find_fluentd before_action :find_fluentd
def show def show
@config = File.read(@fluentd.agent.config_file) # TODO @config = @fluentd.agent.config
end end
def edit def edit
@config = File.read(@fluentd.agent.config_file) # TODO @config = @fluentd.agent.config
end end
def update def update
File.open(@fluentd.agent.config_file, "w") do |f| # TODO: should update by agent class @fluentd.agent.config_write params[:config]
f.write params[:config]
end
@fluentd.agent.restart if @fluentd.agent.running? @fluentd.agent.restart if @fluentd.agent.running?
redirect_to fluentd_setting_path(@fluentd) redirect_to fluentd_setting_path(@fluentd)
end end
@ -54,10 +52,7 @@ class Fluentd::SettingsController < ApplicationController
return render "in_tail_after_format" return render "in_tail_after_format"
end end
File.open(@fluentd.agent.config_file, "a") do |f| # TODO: should update by agent class @fluentd.agent.config_append @setting.to_conf
f.write "\n"
f.write @setting.to_conf
end
@fluentd.agent.restart if @fluentd.agent.running? @fluentd.agent.restart if @fluentd.agent.running?
redirect_to fluentd_setting_path(@fluentd) redirect_to fluentd_setting_path(@fluentd)
end end

View File

@ -45,6 +45,23 @@ class Fluentd
File.read(log_file) # TODO: large log file File.read(log_file) # TODO: large log file
end end
def config
File.read(config_file)
end
def config_write(content)
File.open(config_file, "w") do |f|
f.write content
end
end
def config_append(content)
File.open(config_file, "a") do |f|
f.write "\n"
f.write content
end
end
def errors_since(since = 1.day.ago) def errors_since(since = 1.day.ago)
errors = [] errors = []
logged_errors do |error| logged_errors do |error|

View File

@ -1,7 +1,5 @@
- page_title t('.page_title') - page_title t('.page_title')
-# TODO: should more blush up this page
%table{class: "table table-striped table-hover", id: "plugins-table"} %table{class: "table table-striped table-hover", id: "plugins-table"}
%thead %thead
%tr %tr