Skip to content

Commit 60bd112

Browse files
committed
[grid] Fire event when Node server shuts down
1 parent 3376af0 commit 60bd112

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

java/src/org/openqa/selenium/grid/node/httpd/NodeServer.java

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.openqa.selenium.grid.config.Role;
3535
import org.openqa.selenium.grid.data.NodeAddedEvent;
3636
import org.openqa.selenium.grid.data.NodeDrainComplete;
37+
import org.openqa.selenium.grid.data.NodeRemovedEvent;
3738
import org.openqa.selenium.grid.data.NodeStatusEvent;
3839
import org.openqa.selenium.grid.log.LoggingOptions;
3940
import org.openqa.selenium.grid.node.HealthCheck;
@@ -74,6 +75,8 @@ public class NodeServer extends TemplateGridServerCommand {
7475
private final AtomicBoolean nodeRegistered = new AtomicBoolean(false);
7576
private Node node;
7677
private EventBus bus;
78+
private final Thread shutdownHook =
79+
new Thread(() -> bus.fire(new NodeRemovedEvent(node.getStatus())));
7780

7881
@Override
7982
public String getName() {
@@ -223,6 +226,7 @@ public NettyServer start() {
223226
protected void execute(Config config) {
224227
Require.nonNull("Config", config);
225228

229+
Runtime.getRuntime().addShutdownHook(shutdownHook);
226230
Server<?> server = asServer(config).start();
227231

228232
BuildInfo info = new BuildInfo();

0 commit comments

Comments
 (0)