File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
java/src/org/openqa/selenium/grid/commands Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ java_library(
20
20
"//java/src/org/openqa/selenium/events" ,
21
21
"//java/src/org/openqa/selenium/grid:base-command" ,
22
22
"//java/src/org/openqa/selenium/grid/config" ,
23
+ "//java/src/org/openqa/selenium/grid/data" ,
23
24
"//java/src/org/openqa/selenium/grid/distributor" ,
24
25
"//java/src/org/openqa/selenium/grid/distributor/config" ,
25
26
"//java/src/org/openqa/selenium/grid/distributor/local" ,
Original file line number Diff line number Diff line change 27
27
import org .openqa .selenium .grid .TemplateGridServerCommand ;
28
28
import org .openqa .selenium .grid .config .Config ;
29
29
import org .openqa .selenium .grid .config .Role ;
30
+ import org .openqa .selenium .grid .data .NodeDrainComplete ;
30
31
import org .openqa .selenium .grid .distributor .Distributor ;
31
32
import org .openqa .selenium .grid .distributor .config .DistributorOptions ;
32
33
import org .openqa .selenium .grid .distributor .local .LocalDistributor ;
@@ -204,6 +205,27 @@ protected Handlers createHandlers(Config config) {
204
205
combinedHandler .addHandler (node );
205
206
distributor .add (node );
206
207
208
+ bus .addListener (NodeDrainComplete .listener (nodeId -> {
209
+ if (!node .getId ().equals (nodeId )) {
210
+ return ;
211
+ }
212
+
213
+ // Wait a beat before shutting down so the final response from the
214
+ // node can escape.
215
+ new Thread (
216
+ () -> {
217
+ try {
218
+ Thread .sleep (1000 );
219
+ } catch (InterruptedException e ) {
220
+ // Swallow, the next thing we're doing is shutting down
221
+ }
222
+ LOG .info ("Shutting down" );
223
+ System .exit (0 );
224
+ },
225
+ "Standalone shutdown: " + nodeId )
226
+ .start ();
227
+ }));
228
+
207
229
return new Handlers (httpHandler , new ProxyNodeWebsockets (clientFactory , node ));
208
230
}
209
231
You can’t perform that action at this time.
0 commit comments