Add dryrun method to agents

This commit is contained in:
uu59 2015-01-14 13:38:14 +09:00
parent 8119c5222e
commit f80ab8a69a
3 changed files with 16 additions and 5 deletions

View File

@ -5,7 +5,7 @@ class Fluentd
include LocalCommon include LocalCommon
def self.default_options def self.default_options
{ {
:pid_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.pid", :pid_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.pid",
:log_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.log", :log_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.log",
:config_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.conf", :config_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.conf",
@ -42,6 +42,12 @@ class Fluentd
actual_reload actual_reload
end end
def dryrun
Bundler.with_clean_env do
system("fluentd --dry-run #{options_to_argv}")
end
end
def version def version
Bundler.with_clean_env do Bundler.with_clean_env do
`fluentd --version`.strip `fluentd --version`.strip
@ -60,9 +66,7 @@ class Fluentd
end end
def validate_fluentd_options def validate_fluentd_options
Bundler.with_clean_env do dryrun
system("fluentd --dry-run #{options_to_argv}")
end
end end
def actual_start def actual_start

View File

@ -2,7 +2,6 @@ class Fluentd
class Agent class Agent
class TdAgent class TdAgent
module Macosx module Macosx
def start def start
backup_running_config do backup_running_config do
detached_command("launchctl load #{plist}") && pid_from_launchctl detached_command("launchctl load #{plist}") && pid_from_launchctl
@ -17,6 +16,10 @@ class Fluentd
stop && start stop && start
end end
def dryrun
detached_command("/usr/sbin/td-agent --dry-run -q --use-v1-config -c #{config_file} -o #{log_file}")
end
private private
def plist def plist

View File

@ -17,6 +17,10 @@ class Fluentd
# https://github.com/treasure-data/td-agent/blob/master/debian/td-agent.init#L156 # https://github.com/treasure-data/td-agent/blob/master/debian/td-agent.init#L156
detached_command('/etc/init.d/td-agent restart') detached_command('/etc/init.d/td-agent restart')
end end
def dryrun
detached_command('/etc/init.d/td-agent configtest')
end
end end
end end
end end