bazelbuild / bazelbuild/rules_closure
Cannot shutdown WebfilesServer
- Dominant language
- Java
- Stars
- 159
- Forks
- 111
- PR merge metrics
- No merged PRs in 30d
Description
The [WebfilesServer](https://github.com/bazelbuild/rules_closure/blob/master/java/io/bazel/rules/closure/webfiles/server/WebfilesServer.java) currently lacks a shutdown method.
Simply shutting down the ExecutorService that runs the server doesn't work:
```
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newCachedThreadPool();
WebfilesServer server =
DaggerWebfilesServer_Server.builder()
.args(ImmutableList.of(serverConfig))
.executor(executor)
.fs(FileSystems.getDefault())
.serverSocketFactory(ServerSocketFactory.getDefault())
.build()
.server();
server.spawn();
executor.shutdownNow();
// at this point, the server is still running
}
```
WebfilesServer also contains [MetadataLoader](https://github.com/bazelbuild/rules_closure/blob/master/java/io/bazel/rules/closure/webfiles/server/Metadata.java#L111) and [MetadataReloader](https://github.com/bazelbuild/rules_closure/blob/master/java/io/bazel/rules/closure/webfiles/server/Metadata.java#L190) instances that also implement Runnable and loop infinitely. Some work needs to be done to break the loops and release the resources properly.
Contributor guide
Research direction
Start with java/io/bazel/rules/closure/webfiles/server/WebfilesServer.java and the MetadataLoader and MetadataReloader implementations in Metadata.java. Trace how spawn starts the server and the Runnable loops, then identify how shutdown should stop those loops and release resources. Done means WebfilesServer exposes a shutdown path that stops the server and associated metadata workers cleanly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100