bazelbuild / bazelbuild/rules_closure

Cannot shutdown WebfilesServer

Open
#566 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.