@@ -69,10 +69,6 @@ def wait
69
69
class LogStash ::Runner
70
70
include LogStash ::Program
71
71
72
- def initialize
73
- @runners = [ ]
74
- end
75
-
76
72
def main ( args )
77
73
require "logstash/util"
78
74
require "stud/trap"
@@ -89,23 +85,11 @@ def main(args)
89
85
90
86
Stud ::untrap ( "INT" , @startup_interruption_trap )
91
87
92
- args = [ nil ] if args . empty?
93
-
94
- while args != nil && !args . empty?
95
- args = run ( args )
96
- end
97
-
98
- status = [ ]
99
- @runners . each do |r |
100
- #$stderr.puts "Waiting on #{r.wait.inspect}"
101
- status << r . wait
102
- end
103
-
104
- # Avoid running test/unit's at_exit crap
105
- if status . empty? || status . first . nil?
88
+ if args . empty? then
106
89
exit ( 0 )
107
90
else
108
- exit ( status . first )
91
+ task = run ( args )
92
+ exit ( task . wait )
109
93
end
110
94
end # def self.main
111
95
@@ -118,14 +102,12 @@ def run(args)
118
102
if args . include? ( "--verbose" )
119
103
agent_args << "--verbose"
120
104
end
121
- LogStash ::Agent . run ( $0, agent_args )
122
- return [ ]
105
+ return LogStash ::Agent . run ( $0, agent_args )
123
106
end ,
124
107
"web" => lambda do
125
108
# Give them kibana.
126
109
require "logstash/kibana"
127
110
kibana = LogStash ::Kibana ::Runner . new
128
- @runners << kibana
129
111
return kibana . run ( args )
130
112
end ,
131
113
"rspec" => lambda do
@@ -136,18 +118,11 @@ def run(args)
136
118
require "test_utils"
137
119
all_specs = Dir . glob ( File . join ( spec_path , "/**/*.rb" ) )
138
120
rspec = LogStash ::RSpecsRunner . new ( args . empty? ? all_specs : args )
139
- rspec . run
140
- @runners << rspec
141
- return [ ]
121
+ return rspec . run
142
122
end ,
143
123
"irb" => lambda do
144
124
require "irb"
145
- IRB . start ( __FILE__ )
146
- return [ ]
147
- end ,
148
- "ruby" => lambda do
149
- require ( args [ 0 ] )
150
- return [ ]
125
+ return IRB . start ( __FILE__ )
151
126
end ,
152
127
"pry" => lambda do
153
128
require "pry"
@@ -158,17 +133,11 @@ def run(args)
158
133
plugin_manager = LogStash ::PluginManager ::Main . new ( $0)
159
134
begin
160
135
plugin_manager . parse ( args )
136
+ return plugin_manager . execute
161
137
rescue Clamp ::HelpWanted => e
162
138
show_help ( e . command )
139
+ return 0
163
140
end
164
-
165
- begin
166
- plugin_manager . execute
167
- rescue Clamp ::HelpWanted => e
168
- show_help ( e . command )
169
- end
170
-
171
- return [ ]
172
141
end ,
173
142
"agent" => lambda do
174
143
require "logstash/agent"
@@ -178,21 +147,20 @@ def run(args)
178
147
agent . parse ( args )
179
148
rescue Clamp ::HelpWanted => e
180
149
show_help ( e . command )
181
- return [ ]
150
+ return 0
182
151
rescue Clamp ::UsageError => e
183
152
# If 'too many arguments' then give the arguments to
184
153
# the next command. Otherwise it's a real error.
185
154
raise if e . message != "too many arguments"
186
155
remaining = agent . remaining_arguments
187
156
end
188
- @runners << Stud ::Task . new { agent . execute }
189
157
190
- return remaining
158
+ return agent . execute
191
159
end
192
160
} # commands
193
161
194
162
if commands . include? ( command )
195
- args = commands [ command ] . call
163
+ return Stud :: Task . new { commands [ command ] . call }
196
164
else
197
165
if command . nil?
198
166
$stderr. puts "No command given"
0 commit comments