Add basic status handler to session map
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.google.auto.service.AutoService;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.net.MediaType;
import io.opentracing.Tracer;
import org.openqa.selenium.BuildInfo;
import org.openqa.selenium.cli.CliCommand;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.netty.server.NettyServer;
+import org.openqa.selenium.remote.http.Contents;
+import org.openqa.selenium.remote.http.HttpResponse;
+import org.openqa.selenium.remote.http.Route;
import java.util.logging.Logger;
+import static org.openqa.selenium.remote.http.Route.get;
+
@AutoService(CliCommand.class)
public class SessionMapServer implements CliCommand {
@@ -103,7 +110,12 @@ public Executable configure(String... args) {
BaseServerOptions serverOptions = new BaseServerOptions(config);
- Server<?> server = new NettyServer(serverOptions, sessions);
+ Server<?> server = new NettyServer(serverOptions, Route.combine(
+ sessions,
+ get("/status").to(() -> req ->
+ new HttpResponse()
+ .addHeader("Content-Type", MediaType.JSON_UTF_8.toString())
+ .setContent(Contents.asJson(ImmutableMap.of("ready", true, "message", "Session map is ready."))))));
server.start();
BuildInfo info = new BuildInfo();
