public class WebServer extends Object
The WebServer can be modeled as: a) a network listener/dispatcher which sits on the port and listens for incoming http requests. b) static handlers - list of handlers that are bound to the current process (list of traces/logs/socket), c) 'normal' handlers, bound to the daemon state.
We would like the server to go down as infrequently as possible (this makes it simpler for /ws users who would otherwise need to reconnect and potentially lose state) which is the reason for section c) above.
Modifier and Type | Class and Description |
---|---|
static class |
WebServer.WebServerException |
Constructor and Description |
---|
WebServer(int port,
ProjectFilesystem projectFilesystem,
Clock clock) |
Modifier and Type | Method and Description |
---|---|
WebServerBuckEventListener |
createListener() |
int |
getNumActiveConnections() |
int |
getPort() |
void |
stop() |
void |
updateAndStartIfNeeded(Optional<ArtifactCache> artifactCache)
Update state and start the server if necessary.
|
public WebServer(int port, ProjectFilesystem projectFilesystem, Clock clock)
port
- If 0, then an ephemeral
port will be assigned. Use getPort()
to find out which port is being used.public int getPort()
public WebServerBuckEventListener createListener()
public int getNumActiveConnections()
public void updateAndStartIfNeeded(Optional<ArtifactCache> artifactCache) throws WebServer.WebServerException
artifactCache
- cache to serve.WebServer.WebServerException
public void stop() throws WebServer.WebServerException
WebServer.WebServerException