File tree Expand file tree Collapse file tree
java/src/org/openqa/selenium/grid/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ java_library(
2020 "//java/src/org/openqa/selenium/events" ,
2121 "//java/src/org/openqa/selenium/grid:base-command" ,
2222 "//java/src/org/openqa/selenium/grid/config" ,
23+ "//java/src/org/openqa/selenium/grid/data" ,
2324 "//java/src/org/openqa/selenium/grid/distributor" ,
2425 "//java/src/org/openqa/selenium/grid/distributor/config" ,
2526 "//java/src/org/openqa/selenium/grid/distributor/local" ,
Original file line number Diff line number Diff line change 2727import org .openqa .selenium .grid .TemplateGridServerCommand ;
2828import org .openqa .selenium .grid .config .Config ;
2929import org .openqa .selenium .grid .config .Role ;
30+ import org .openqa .selenium .grid .data .NodeDrainComplete ;
3031import org .openqa .selenium .grid .distributor .Distributor ;
3132import org .openqa .selenium .grid .distributor .config .DistributorOptions ;
3233import org .openqa .selenium .grid .distributor .local .LocalDistributor ;
@@ -204,6 +205,27 @@ protected Handlers createHandlers(Config config) {
204205 combinedHandler .addHandler (node );
205206 distributor .add (node );
206207
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+
207229 return new Handlers (httpHandler , new ProxyNodeWebsockets (clientFactory , node ));
208230 }
209231
You can’t perform that action at this time.
0 commit comments