tolerate bad path.settings when --help is present

Fixes #5786
This commit is contained in:
Joao Duarte 2016-08-19 14:23:51 +01:00 committed by João Duarte
parent ebed7247e6
commit bb46aa6188
2 changed files with 22 additions and 1 deletions

View file

@ -151,7 +151,9 @@ class LogStash::Runner < Clamp::StrictCommand
@logger.subscribe(STDOUT)
@logger.warn("Logstash has a new settings file which defines start up time settings. This file is typically located in $LS_HOME/config or /etc/logstash. If you installed Logstash through a package and are starting it manually please specify the location to this settings file by passing in \"--path.settings=/path/..\" in the command line options")
@logger.fatal("Failed to load settings file from \"path.settings\". Aborting...", "path.settings" => LogStash::SETTINGS.get("path.settings"), "exception" => e.class, "message" => e.message)
exit(-1)
# abort unless we're just looking for the help
return(1) if (["--help", "-h"] & args).empty?
end
super(*[args])

View file

@ -328,4 +328,23 @@ describe LogStash::Runner do
end
end
end
describe "path.settings" do
subject { LogStash::Runner.new("") }
context "if does not exist" do
let(:args) { ["--path.settings", "/tmp/a/a/a/a", "-e", "input {} output {}"] }
it "should terminate logstash" do
expect(subject.run(args)).to eq(1)
end
context "but --help is passed" do
let(:args) { ["--path.settings", "/tmp/a/a/a/a", "--help"] }
it "should show help" do
expect { subject.run(args) }.to raise_error(Clamp::HelpWanted)
end
end
end
end
end