Principle:SeleniumHQ Selenium Grid Bootstrap Process
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Testing, Process_Management, Selenium_Grid |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Entry point mechanism for starting Selenium Grid components through a CLI router that delegates to ServiceLoader-discovered commands.
Description
The Grid bootstrap process starts with Bootstrap.main(), which handles extension loading (via --ext classpath additions using a custom PossessiveClassLoader), then delegates to Main.main() via reflection. Main uses Java's ServiceLoader to discover all CliCommand implementations (annotated with @AutoService(CliCommand.class)), sorts them by name, matches the first CLI argument (args[0]) to a command name, and invokes its configure(out, err, remainingArgs) method to obtain an Executable, then calls run(). If no argument matches, a built-in Help command lists all available commands. This extensible architecture allows plugins to register custom Grid commands by placing JARs on the --ext classpath.
Usage
This is the standard way to start any Grid component. Understanding the bootstrap process is important for debugging startup failures, adding custom extensions, or creating custom Grid commands.
Theoretical Basis
# Pseudocode: Grid Bootstrap
1. Bootstrap.main(args):
a. If args[0] == "--ext":
- Parse args[1] as extension JAR paths (File.pathSeparator-delimited)
- Create URLClassLoader with extension JARs
- Wrap in PossessiveClassLoader (child-first class loading)
- Set as thread context classloader
- Remove first two args
b. Reflectively load and invoke Main.main(remainingArgs)
2. Main.main(args):
a. Create new Main(System.out, System.err, args)
b. If args is empty: show help
c. Else: launch(args, classloader)
3. Main.launch(args, classloader):
a. ServiceLoader.load(CliCommand.class, loader) -> discover all commands
b. Sort commands by name
c. Match args[0] to command.getName()
d. command.configure(out, err, remainingArgs) -> Executable
e. executable.run() -> Start Grid component
4. Available commands: standalone, hub, node, distributor, router, sessions, sessionqueue