logstash-core 2.4.1-java → 5.0.0.alpha1-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash/agent.rb +124 -411
- data/lib/logstash/api/init.ru +31 -0
- data/lib/logstash/api/lib/app.rb +40 -0
- data/lib/logstash/api/lib/app/command.rb +29 -0
- data/lib/logstash/api/lib/app/command_factory.rb +29 -0
- data/lib/logstash/api/lib/app/commands/stats/events_command.rb +13 -0
- data/lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb +120 -0
- data/lib/logstash/api/lib/app/commands/stats/memory_command.rb +25 -0
- data/lib/logstash/api/lib/app/commands/system/basicinfo_command.rb +15 -0
- data/lib/logstash/api/lib/app/commands/system/plugins_command.rb +28 -0
- data/lib/logstash/api/lib/app/modules/node.rb +25 -0
- data/lib/logstash/api/lib/app/modules/node_stats.rb +51 -0
- data/lib/logstash/api/lib/app/modules/plugins.rb +15 -0
- data/lib/logstash/api/lib/app/modules/stats.rb +21 -0
- data/lib/logstash/api/lib/app/root.rb +13 -0
- data/lib/logstash/api/lib/app/service.rb +61 -0
- data/lib/logstash/api/lib/app/stats.rb +56 -0
- data/lib/logstash/api/lib/helpers/app_helpers.rb +23 -0
- data/lib/logstash/codecs/base.rb +1 -29
- data/lib/logstash/config/config_ast.rb +18 -31
- data/lib/logstash/config/loader.rb +3 -5
- data/lib/logstash/config/mixin.rb +25 -64
- data/lib/logstash/filter_delegator.rb +65 -0
- data/lib/logstash/inputs/base.rb +1 -1
- data/lib/logstash/inputs/metrics.rb +47 -0
- data/lib/logstash/instrument/collector.rb +109 -0
- data/lib/logstash/instrument/metric.rb +102 -0
- data/lib/logstash/instrument/metric_store.rb +228 -0
- data/lib/logstash/instrument/metric_type.rb +24 -0
- data/lib/logstash/instrument/metric_type/base.rb +35 -0
- data/lib/logstash/instrument/metric_type/counter.rb +29 -0
- data/lib/logstash/instrument/metric_type/gauge.rb +22 -0
- data/lib/logstash/instrument/metric_type/mean.rb +33 -0
- data/lib/logstash/instrument/namespaced_metric.rb +54 -0
- data/lib/logstash/instrument/null_metric.rb +4 -3
- data/lib/logstash/instrument/periodic_poller/base.rb +57 -0
- data/lib/logstash/instrument/periodic_poller/jvm.rb +92 -0
- data/lib/logstash/instrument/periodic_poller/os.rb +13 -0
- data/lib/logstash/instrument/periodic_poller/periodic_poller_observer.rb +19 -0
- data/lib/logstash/instrument/periodic_pollers.rb +26 -0
- data/lib/logstash/instrument/snapshot.rb +16 -0
- data/lib/logstash/json.rb +2 -3
- data/lib/logstash/namespace.rb +1 -0
- data/lib/logstash/output_delegator.rb +16 -3
- data/lib/logstash/outputs/base.rb +1 -32
- data/lib/logstash/pipeline.rb +67 -8
- data/lib/logstash/plugin.rb +57 -19
- data/lib/logstash/runner.rb +348 -84
- data/lib/logstash/util.rb +9 -0
- data/lib/logstash/util/duration_formatter.rb +15 -0
- data/lib/logstash/util/java_version.rb +2 -4
- data/lib/logstash/util/loggable.rb +29 -0
- data/lib/logstash/version.rb +1 -1
- data/lib/logstash/webserver.rb +98 -0
- data/locales/en.yml +42 -24
- data/logstash-core.gemspec +9 -6
- data/spec/api/lib/api/node_spec.rb +64 -0
- data/spec/api/lib/api/node_stats_spec.rb +68 -0
- data/spec/api/lib/api/plugins_spec.rb +57 -0
- data/spec/api/lib/api/root_spec.rb +20 -0
- data/spec/api/lib/api/stats_spec.rb +19 -0
- data/spec/api/lib/commands/events_spec.rb +17 -0
- data/spec/api/lib/commands/jvm_spec.rb +45 -0
- data/spec/api/spec_helper.rb +128 -0
- data/spec/logstash/agent_spec.rb +62 -169
- data/spec/logstash/config/config_ast_spec.rb +2 -47
- data/spec/logstash/config/mixin_spec.rb +0 -157
- data/spec/logstash/filter_delegator_spec.rb +143 -0
- data/spec/logstash/inputs/metrics_spec.rb +52 -0
- data/spec/logstash/instrument/collector_spec.rb +49 -0
- data/spec/logstash/instrument/metric_spec.rb +110 -0
- data/spec/logstash/instrument/metric_store_spec.rb +163 -0
- data/spec/logstash/instrument/metric_type/counter_spec.rb +40 -0
- data/spec/logstash/instrument/metric_type/gauge_spec.rb +40 -0
- data/spec/logstash/instrument/namespaced_metric_spec.rb +25 -0
- data/spec/logstash/instrument/null_metric_spec.rb +9 -51
- data/spec/logstash/json_spec.rb +14 -0
- data/spec/logstash/output_delegator_spec.rb +6 -3
- data/spec/logstash/outputs/base_spec.rb +0 -107
- data/spec/logstash/pipeline_spec.rb +204 -33
- data/spec/logstash/plugin_spec.rb +80 -15
- data/spec/logstash/runner_spec.rb +134 -38
- data/spec/logstash/shutdown_watcher_spec.rb +0 -1
- data/spec/logstash/util/duration_formatter_spec.rb +11 -0
- data/spec/logstash/util/java_version_spec.rb +10 -2
- data/spec/logstash/util_spec.rb +28 -0
- data/spec/support/matchers.rb +30 -0
- metadata +154 -20
- data/lib/logstash/logging/json.rb +0 -21
- data/lib/logstash/special_agent.rb +0 -8
- data/lib/logstash/util/safe_uri.rb +0 -50
- data/spec/logstash/codecs/base_spec.rb +0 -74
- data/spec/static/i18n_spec.rb +0 -25
data/lib/logstash/runner.rb
CHANGED
@@ -3,26 +3,144 @@ Thread.abort_on_exception = true
|
|
3
3
|
Encoding.default_external = Encoding::UTF_8
|
4
4
|
$DEBUGLIST = (ENV["DEBUG"] || "").split(",")
|
5
5
|
|
6
|
+
require "clamp" # gem 'clamp'
|
7
|
+
require "net/http"
|
6
8
|
require "logstash/environment"
|
7
9
|
|
8
10
|
LogStash::Environment.load_locale!
|
9
11
|
|
10
12
|
require "logstash/namespace"
|
11
|
-
require "logstash/
|
13
|
+
require "logstash/agent"
|
12
14
|
require "logstash/config/defaults"
|
13
15
|
|
14
|
-
class LogStash::Runner
|
15
|
-
|
16
|
+
class LogStash::Runner < Clamp::Command
|
17
|
+
|
18
|
+
option ["-f", "--config"], "CONFIG_PATH",
|
19
|
+
I18n.t("logstash.runner.flag.config"),
|
20
|
+
:attribute_name => :config_path
|
21
|
+
|
22
|
+
option "-e", "CONFIG_STRING",
|
23
|
+
I18n.t("logstash.runner.flag.config-string",
|
24
|
+
:default_input => LogStash::Config::Defaults.input,
|
25
|
+
:default_output => LogStash::Config::Defaults.output),
|
26
|
+
:default => nil, :attribute_name => :config_string
|
27
|
+
|
28
|
+
option ["-w", "--pipeline-workers"], "COUNT",
|
29
|
+
I18n.t("logstash.runner.flag.pipeline-workers"),
|
30
|
+
:attribute_name => :pipeline_workers,
|
31
|
+
:default => LogStash::Pipeline::DEFAULT_SETTINGS[:default_pipeline_workers]
|
32
|
+
|
33
|
+
option ["-b", "--pipeline-batch-size"], "SIZE",
|
34
|
+
I18n.t("logstash.runner.flag.pipeline-batch-size"),
|
35
|
+
:attribute_name => :pipeline_batch_size,
|
36
|
+
:default => LogStash::Pipeline::DEFAULT_SETTINGS[:pipeline_batch_size]
|
37
|
+
|
38
|
+
option ["-u", "--pipeline-batch-delay"], "DELAY_IN_MS",
|
39
|
+
I18n.t("logstash.runner.flag.pipeline-batch-delay"),
|
40
|
+
:attribute_name => :pipeline_batch_delay,
|
41
|
+
:default => LogStash::Pipeline::DEFAULT_SETTINGS[:pipeline_batch_delay]
|
42
|
+
|
43
|
+
option ["-l", "--log"], "FILE",
|
44
|
+
I18n.t("logstash.runner.flag.log"),
|
45
|
+
:attribute_name => :log_file
|
46
|
+
|
47
|
+
# Old support for the '-v' flag'
|
48
|
+
option "-v", :flag,
|
49
|
+
I18n.t("logstash.runner.flag.verbosity"),
|
50
|
+
:attribute_name => :verbosity, :multivalued => true
|
51
|
+
|
52
|
+
option "--quiet", :flag, I18n.t("logstash.runner.flag.quiet")
|
53
|
+
option "--verbose", :flag, I18n.t("logstash.runner.flag.verbose")
|
54
|
+
option "--debug", :flag, I18n.t("logstash.runner.flag.debug")
|
55
|
+
|
56
|
+
option ["--debug-config"], :flag,
|
57
|
+
I18n.t("logstash.runner.flag.debug_config"),
|
58
|
+
:attribute_name => :debug_config, :default => false
|
59
|
+
|
60
|
+
option ["-V", "--version"], :flag,
|
61
|
+
I18n.t("logstash.runner.flag.version")
|
62
|
+
|
63
|
+
option ["-p", "--pluginpath"] , "PATH",
|
64
|
+
I18n.t("logstash.runner.flag.pluginpath"),
|
65
|
+
:multivalued => true,
|
66
|
+
:attribute_name => :plugin_paths
|
67
|
+
|
68
|
+
option ["-t", "--configtest"], :flag,
|
69
|
+
I18n.t("logstash.runner.flag.configtest"),
|
70
|
+
:attribute_name => :config_test
|
71
|
+
|
72
|
+
option "--[no-]allow-unsafe-shutdown", :flag,
|
73
|
+
I18n.t("logstash.runner.flag.unsafe_shutdown"),
|
74
|
+
:attribute_name => :unsafe_shutdown,
|
75
|
+
:default => false
|
76
|
+
|
77
|
+
option ["-i", "--interactive"], "SHELL",
|
78
|
+
I18n.t("logstash.runner.flag.rubyshell"),
|
79
|
+
:attribute_name => :ruby_shell
|
80
|
+
|
81
|
+
option ["-n", "--node-name"], "NAME",
|
82
|
+
I18n.t("logstash.runner.flag.node_name"),
|
83
|
+
:attribute_name => :node_name
|
84
|
+
|
85
|
+
option ["-r", "--[no-]auto-reload"], :flag,
|
86
|
+
I18n.t("logstash.runner.flag.auto_reload"),
|
87
|
+
:attribute_name => :auto_reload, :default => false
|
88
|
+
|
89
|
+
option ["--reload-interval"], "RELOAD_INTERVAL",
|
90
|
+
I18n.t("logstash.runner.flag.reload_interval"),
|
91
|
+
:attribute_name => :reload_interval, :default => 3, &:to_i
|
92
|
+
|
93
|
+
option ["--http-host"], "WEB_API_HTTP_HOST",
|
94
|
+
I18n.t("logstash.web_api.flag.http_host"),
|
95
|
+
:attribute_name => :web_api_http_host, :default => "127.0.0.1"
|
96
|
+
|
97
|
+
option ["--http-port"], "WEB_API_HTTP_PORT",
|
98
|
+
I18n.t("logstash.web_api.flag.http_port"),
|
99
|
+
:attribute_name => :web_api_http_port, :default => 9600
|
100
|
+
|
101
|
+
option ["--allow-env"], :flag,
|
102
|
+
I18n.t("logstash.runner.flag.allow-env"),
|
103
|
+
:attribute_name => :allow_env, :default => false
|
104
|
+
|
105
|
+
def pipeline_workers=(pipeline_workers_value)
|
106
|
+
@pipeline_settings[:pipeline_workers] = validate_positive_integer(pipeline_workers_value)
|
107
|
+
end
|
108
|
+
|
109
|
+
def pipeline_batch_size=(pipeline_batch_size_value)
|
110
|
+
@pipeline_settings[:pipeline_batch_size] = validate_positive_integer(pipeline_batch_size_value)
|
111
|
+
end
|
112
|
+
|
113
|
+
def pipeline_batch_delay=(pipeline_batch_delay_value)
|
114
|
+
@pipeline_settings[:pipeline_batch_delay] = validate_positive_integer(pipeline_batch_delay_value)
|
115
|
+
end
|
116
|
+
|
117
|
+
def validate_positive_integer(str_arg)
|
118
|
+
int_arg = str_arg.to_i
|
119
|
+
if str_arg !~ /^\d+$/ || int_arg < 1
|
120
|
+
raise ArgumentError, "Expected a positive integer, got '#{str_arg}'"
|
121
|
+
end
|
122
|
+
|
123
|
+
int_arg
|
124
|
+
end
|
16
125
|
|
17
126
|
attr_reader :agent
|
18
127
|
|
19
|
-
def
|
128
|
+
def initialize(*args)
|
129
|
+
@logger = Cabin::Channel.get(LogStash)
|
130
|
+
@pipeline_settings ||= { :pipeline_id => "main" }
|
131
|
+
super(*args)
|
132
|
+
end
|
20
133
|
|
134
|
+
def execute
|
21
135
|
require "logstash/util"
|
22
136
|
require "logstash/util/java_version"
|
23
|
-
require "stud/trap"
|
24
137
|
require "stud/task"
|
25
|
-
|
138
|
+
require "cabin" # gem 'cabin'
|
139
|
+
|
140
|
+
|
141
|
+
# Configure Logstash logging facility, this need to be done before everything else to
|
142
|
+
# make sure the logger has the correct settings and the log level is correctly defined.
|
143
|
+
configure_logging(log_file)
|
26
144
|
|
27
145
|
LogStash::Util::set_thread_name(self.class.name)
|
28
146
|
|
@@ -34,96 +152,242 @@ class LogStash::Runner
|
|
34
152
|
# Print a warning to STDERR for bad java versions
|
35
153
|
LogStash::Util::JavaVersion.warn_on_bad_java_version
|
36
154
|
|
37
|
-
|
155
|
+
LogStash::ShutdownWatcher.unsafe_shutdown = unsafe_shutdown?
|
156
|
+
LogStash::ShutdownWatcher.logger = @logger
|
38
157
|
|
39
|
-
|
40
|
-
exit(task.wait)
|
41
|
-
end # def self.main
|
158
|
+
configure
|
42
159
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
"pry" => lambda do
|
59
|
-
require "pry"
|
60
|
-
return binding.pry
|
61
|
-
end,
|
62
|
-
"docgen" => lambda do
|
63
|
-
require 'docs/asciidocgen'
|
64
|
-
opts = OptionParser.new
|
65
|
-
settings = {}
|
66
|
-
opts.on("-o DIR", "--output DIR",
|
67
|
-
"Directory to output to; optional. If not specified,"\
|
68
|
-
"we write to stdout.") do |val|
|
69
|
-
settings[:output] = val
|
70
|
-
end
|
71
|
-
args = opts.parse(ARGV)
|
72
|
-
docs = LogStashConfigAsciiDocGenerator.new
|
73
|
-
args.each do |arg|
|
74
|
-
docs.generate(arg, settings)
|
75
|
-
end
|
76
|
-
return 0
|
77
|
-
end,
|
78
|
-
"agent" => lambda do
|
79
|
-
require "logstash/agent"
|
80
|
-
# Hack up a runner
|
81
|
-
agent = LogStash::Agent.new("/bin/logstash agent", $0)
|
82
|
-
begin
|
83
|
-
agent.parse(args)
|
84
|
-
rescue Clamp::HelpWanted => e
|
85
|
-
show_help(e.command)
|
86
|
-
return 0
|
87
|
-
rescue Clamp::UsageError => e
|
88
|
-
# If 'too many arguments' then give the arguments to
|
89
|
-
# the next command. Otherwise it's a real error.
|
90
|
-
raise if e.message != "too many arguments"
|
91
|
-
remaining = agent.remaining_arguments
|
92
|
-
end
|
160
|
+
if version?
|
161
|
+
show_version
|
162
|
+
return 0
|
163
|
+
end
|
164
|
+
|
165
|
+
return start_shell(@ruby_shell, binding) if @ruby_shell
|
166
|
+
|
167
|
+
if config_string.nil? && config_path.nil?
|
168
|
+
fail(I18n.t("logstash.runner.missing-configuration"))
|
169
|
+
end
|
170
|
+
|
171
|
+
if @auto_reload && config_path.nil?
|
172
|
+
# there's nothing to reload
|
173
|
+
signal_usage_error(I18n.t("logstash.runner.reload-without-config-path"))
|
174
|
+
end
|
93
175
|
|
94
|
-
|
176
|
+
if config_test?
|
177
|
+
config_loader = LogStash::Config::Loader.new(@logger, @debug_config)
|
178
|
+
config_str = config_loader.format_config(config_path, config_string)
|
179
|
+
begin
|
180
|
+
LogStash::Pipeline.new(config_str)
|
181
|
+
@logger.terminal "Configuration OK"
|
182
|
+
return 0
|
183
|
+
rescue => e
|
184
|
+
@logger.fatal I18n.t("logstash.runner.invalid-configuration", :error => e.message)
|
185
|
+
return 1
|
95
186
|
end
|
96
|
-
|
187
|
+
end
|
188
|
+
|
189
|
+
@agent = create_agent(:logger => @logger,
|
190
|
+
:auto_reload => @auto_reload,
|
191
|
+
:reload_interval => @reload_interval,
|
192
|
+
:collect_metric => true,
|
193
|
+
:debug => debug?,
|
194
|
+
:node_name => node_name,
|
195
|
+
:debug_config => debug_config?,
|
196
|
+
:web_api_http_host => @web_api_http_host,
|
197
|
+
:web_api_http_port => @web_api_http_port)
|
97
198
|
|
98
|
-
|
99
|
-
|
199
|
+
@agent.register_pipeline("main", @pipeline_settings.merge({
|
200
|
+
:config_string => config_string,
|
201
|
+
:config_path => config_path,
|
202
|
+
:debug_config => debug_config?,
|
203
|
+
:allow_env => allow_env?
|
204
|
+
}))
|
205
|
+
|
206
|
+
# enable sigint/sigterm before starting the agent
|
207
|
+
# to properly handle a stalled agent
|
208
|
+
sigint_id = trap_sigint()
|
209
|
+
sigterm_id = trap_sigterm()
|
210
|
+
|
211
|
+
@agent_task = Stud::Task.new { @agent.execute }
|
212
|
+
|
213
|
+
# no point in enabling config reloading before the agent starts
|
214
|
+
sighup_id = trap_sighup()
|
215
|
+
|
216
|
+
agent_return = @agent_task.wait
|
217
|
+
|
218
|
+
@agent.shutdown
|
219
|
+
|
220
|
+
agent_return
|
221
|
+
|
222
|
+
rescue Clamp::UsageError => e
|
223
|
+
$stderr.puts "ERROR: #{e.message}"
|
224
|
+
show_short_help
|
225
|
+
return 1
|
226
|
+
rescue => e
|
227
|
+
@logger.fatal(I18n.t("oops"), :error => e, :backtrace => e.backtrace)
|
228
|
+
return 1
|
229
|
+
ensure
|
230
|
+
Stud::untrap("INT", sigint_id) unless sigint_id.nil?
|
231
|
+
Stud::untrap("TERM", sigterm_id) unless sigterm_id.nil?
|
232
|
+
Stud::untrap("HUP", sighup_id) unless sighup_id.nil?
|
233
|
+
@log_fd.close if @log_fd
|
234
|
+
end # def self.main
|
235
|
+
|
236
|
+
def show_version
|
237
|
+
show_version_logstash
|
238
|
+
|
239
|
+
if [:info, :debug].include?(verbosity?) || debug? || verbose?
|
240
|
+
show_version_ruby
|
241
|
+
show_version_java if LogStash::Environment.jruby?
|
242
|
+
show_gems if [:debug].include?(verbosity?) || debug?
|
243
|
+
end
|
244
|
+
end # def show_version
|
245
|
+
|
246
|
+
def show_version_logstash
|
247
|
+
require "logstash/version"
|
248
|
+
puts "logstash #{LOGSTASH_VERSION}"
|
249
|
+
end # def show_version_logstash
|
250
|
+
|
251
|
+
def show_version_ruby
|
252
|
+
puts RUBY_DESCRIPTION
|
253
|
+
end # def show_version_ruby
|
254
|
+
|
255
|
+
def show_version_java
|
256
|
+
properties = java.lang.System.getProperties
|
257
|
+
puts "java #{properties["java.version"]} (#{properties["java.vendor"]})"
|
258
|
+
puts "jvm #{properties["java.vm.name"]} / #{properties["java.vm.version"]}"
|
259
|
+
end # def show_version_java
|
260
|
+
|
261
|
+
def show_gems
|
262
|
+
require "rubygems"
|
263
|
+
Gem::Specification.each do |spec|
|
264
|
+
puts "gem #{spec.name} #{spec.version}"
|
265
|
+
end
|
266
|
+
end # def show_gems
|
267
|
+
|
268
|
+
# Do any start-time configuration.
|
269
|
+
#
|
270
|
+
# Log file stuff, plugin path checking, etc.
|
271
|
+
def configure
|
272
|
+
configure_plugin_paths(plugin_paths)
|
273
|
+
end # def configure
|
274
|
+
|
275
|
+
# add the given paths for ungemified/bare plugins lookups
|
276
|
+
# @param paths [String, Array<String>] plugins path string or list of path strings to add
|
277
|
+
def configure_plugin_paths(paths)
|
278
|
+
Array(paths).each do |path|
|
279
|
+
fail(I18n.t("logstash.runner.configuration.plugin_path_missing", :path => path)) unless File.directory?(path)
|
280
|
+
LogStash::Environment.add_plugin_path(path)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def create_agent(*args)
|
285
|
+
LogStash::Agent.new(*args)
|
286
|
+
end
|
287
|
+
|
288
|
+
# Point logging at a specific path.
|
289
|
+
def configure_logging(path)
|
290
|
+
@logger = Cabin::Channel.get(LogStash)
|
291
|
+
# Set with the -v (or -vv...) flag
|
292
|
+
if quiet?
|
293
|
+
@logger.level = :error
|
294
|
+
elsif verbose?
|
295
|
+
@logger.level = :info
|
296
|
+
elsif debug?
|
297
|
+
@logger.level = :debug
|
100
298
|
else
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if
|
105
|
-
|
106
|
-
|
299
|
+
# Old support for the -v and -vv stuff.
|
300
|
+
if verbosity? && verbosity?.any?
|
301
|
+
# this is an array with length of how many times the flag is given
|
302
|
+
if verbosity?.length == 1
|
303
|
+
@logger.warn("The -v flag is deprecated and will be removed in a future release. You should use --verbose instead.")
|
304
|
+
@logger.level = :info
|
305
|
+
else
|
306
|
+
@logger.warn("The -vv flag is deprecated and will be removed in a future release. You should use --debug instead.")
|
307
|
+
@logger.level = :debug
|
107
308
|
end
|
309
|
+
else
|
310
|
+
@logger.level = :warn
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
if log_file
|
315
|
+
# TODO(sissel): Implement file output/rotation in Cabin.
|
316
|
+
# TODO(sissel): Catch exceptions, report sane errors.
|
317
|
+
begin
|
318
|
+
@log_fd.close if @log_fd
|
319
|
+
@log_fd = File.new(path, "a")
|
320
|
+
rescue => e
|
321
|
+
fail(I18n.t("logstash.runner.configuration.log_file_failed",
|
322
|
+
:path => path, :error => e))
|
108
323
|
end
|
109
|
-
$stderr.puts %q[
|
110
|
-
Usage: logstash <command> [command args]
|
111
|
-
Run a command with the --help flag to see the arguments.
|
112
|
-
For example: logstash agent --help
|
113
324
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
325
|
+
@logger.subscribe(STDOUT, :level => :fatal)
|
326
|
+
@logger.subscribe(@log_fd)
|
327
|
+
@logger.terminal "Sending logstash logs to #{path}."
|
328
|
+
else
|
329
|
+
@logger.subscribe(STDOUT)
|
330
|
+
end
|
331
|
+
|
332
|
+
if debug_config? && @logger.level != :debug
|
333
|
+
@logger.warn("--debug-config was specified, but log level was not set to --debug! No config info will be logged.")
|
120
334
|
end
|
121
|
-
end # def run
|
122
335
|
|
123
|
-
|
336
|
+
# TODO(sissel): redirect stdout/stderr to the log as well
|
337
|
+
# http://jira.codehaus.org/browse/JRUBY-7003
|
338
|
+
end # def configure_logging
|
339
|
+
|
340
|
+
# Emit a failure message and abort.
|
341
|
+
def fail(message)
|
342
|
+
signal_usage_error(message)
|
343
|
+
end # def fail
|
344
|
+
|
345
|
+
def show_short_help
|
346
|
+
puts I18n.t("logstash.runner.short-help")
|
347
|
+
end
|
124
348
|
|
125
|
-
def
|
126
|
-
|
349
|
+
def start_shell(shell, start_binding)
|
350
|
+
case shell
|
351
|
+
when "pry"
|
352
|
+
require 'pry'
|
353
|
+
start_binding.pry
|
354
|
+
when "irb"
|
355
|
+
require 'irb'
|
356
|
+
ARGV.clear
|
357
|
+
# TODO: set binding to this instance of Runner
|
358
|
+
# currently bugged as per https://github.com/jruby/jruby/issues/384
|
359
|
+
IRB.start(__FILE__)
|
360
|
+
else
|
361
|
+
fail(I18n.t("logstash.runner.invalid-shell"))
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
def trap_sighup
|
366
|
+
Stud::trap("HUP") do
|
367
|
+
@logger.warn(I18n.t("logstash.agent.sighup"))
|
368
|
+
@agent.reload_state!
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
def trap_sigterm
|
373
|
+
Stud::trap("TERM") do
|
374
|
+
@logger.warn(I18n.t("logstash.agent.sigterm"))
|
375
|
+
@agent_task.stop!
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def trap_sigint
|
380
|
+
Stud::trap("INT") do
|
381
|
+
if @interrupted_once
|
382
|
+
@logger.fatal(I18n.t("logstash.agent.forced_sigint"))
|
383
|
+
exit
|
384
|
+
else
|
385
|
+
@logger.warn(I18n.t("logstash.agent.sigint"))
|
386
|
+
Thread.new(@logger) {|logger| sleep 5; logger.warn(I18n.t("logstash.agent.slow_shutdown")) }
|
387
|
+
@interrupted_once = true
|
388
|
+
@agent_task.stop!
|
389
|
+
end
|
390
|
+
end
|
127
391
|
end
|
128
392
|
|
129
393
|
end # class LogStash::Runner
|