Skip to content

Commit e7afeaf

Browse files
committed
Add basic status handler to session map
1 parent a83bb41 commit e7afeaf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

java/server/src/org/openqa/selenium/grid/sessionmap/httpd/SessionMapServer.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.beust.jcommander.JCommander;
2121
import com.beust.jcommander.ParameterException;
2222
import com.google.auto.service.AutoService;
23+
import com.google.common.collect.ImmutableMap;
24+
import com.google.common.net.MediaType;
2325
import io.opentracing.Tracer;
2426
import org.openqa.selenium.BuildInfo;
2527
import org.openqa.selenium.cli.CliCommand;
@@ -39,9 +41,14 @@
3941
import org.openqa.selenium.grid.sessionmap.SessionMap;
4042
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
4143
import org.openqa.selenium.netty.server.NettyServer;
44+
import org.openqa.selenium.remote.http.Contents;
45+
import org.openqa.selenium.remote.http.HttpResponse;
46+
import org.openqa.selenium.remote.http.Route;
4247

4348
import java.util.logging.Logger;
4449

50+
import static org.openqa.selenium.remote.http.Route.get;
51+
4552
@AutoService(CliCommand.class)
4653
public class SessionMapServer implements CliCommand {
4754

@@ -103,7 +110,12 @@ public Executable configure(String... args) {
103110

104111
BaseServerOptions serverOptions = new BaseServerOptions(config);
105112

106-
Server<?> server = new NettyServer(serverOptions, sessions);
113+
Server<?> server = new NettyServer(serverOptions, Route.combine(
114+
sessions,
115+
get("/status").to(() -> req ->
116+
new HttpResponse()
117+
.addHeader("Content-Type", MediaType.JSON_UTF_8.toString())
118+
.setContent(Contents.asJson(ImmutableMap.of("ready", true, "message", "Session map is ready."))))));
107119
server.start();
108120

109121
BuildInfo info = new BuildInfo();

0 commit comments

Comments
 (0)