mirror of https://github.com/sbt/sbt.git
Updated Client server discovery lifecycle (markdown)
parent
762b692882
commit
37113a7142
|
|
@ -96,8 +96,8 @@ We create a new interface for the sbt launcher, called `xsbt.ServerMain`:
|
|||
package xsbti;
|
||||
|
||||
public interface ServerMain {
|
||||
public ServerPort[] start(AppConfiguration configuration, ShutdownService shutdown);
|
||||
public boolean isAlive(ServerPort[] ports);
|
||||
public java.net.URI[] start(AppConfiguration configuration);
|
||||
public boolean isAlive(java.net.URI[] listenPorts);
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -108,30 +108,6 @@ The interface has two methods. One responsible for starting the Server, and ano
|
|||
3. Checking to see if the old server is alive. If so, report these ports to the client (TODO - how?)
|
||||
4. If the old server was not alive, start up a new server (fork + detach?). Write the new server bindings to the lock file.
|
||||
|
||||
Port bindings come in triples of `Address`, `Port` and `Protocol` mappings:
|
||||
Port bindings come in java.net.URI, which includes an address, a protocol and a port. The server will actually also write down the PID (process ID) of the server (assuming it can obtain the pid). This enables clients to "kill rogue sbt server" directly.
|
||||
|
||||
```java
|
||||
package xsbti;
|
||||
|
||||
interface ServerPort {
|
||||
public java.net.INetAddress address(); // Can be IPv6 or IPv4
|
||||
public int port();
|
||||
public String protocol(); // A string-based definition of protocol, i.e. http, https
|
||||
// or even custom, like sbt
|
||||
}
|
||||
```
|
||||
|
||||
Clients should be able to be notified of all open ServerPort bindings created by a server.
|
||||
|
||||
|
||||
The shutdown service, passed to a server is designed so that the server itself can determine when it needs to go away. For example, sbt may want to shutdown its own server when there are no remaining connected clients, or after a timeout. The shutdown service has a single method, which tells the sbt-launcher to obtain the lock file and remove any active port bindings from the current server in the lock file:
|
||||
|
||||
```java
|
||||
package xsbti;
|
||||
|
||||
interface ShutdownService {
|
||||
void shutdownServer(ServerPort[] activePorts);
|
||||
}
|
||||
```
|
||||
|
||||
The server should not actually release ports until the ShutdownService call returns, this way ensuring that new services that may be starting up don't grab the same port and have our shutdown blow away their configuration.
|
||||
Clients should be able to be notified of all open ServerPort bindings created by a server.
|
||||
Loading…
Reference in New Issue