diff --git a/Client-server-discovery-lifecycle.md b/Client-server-discovery-lifecycle.md index 8f95a95..749efcd 100644 --- a/Client-server-discovery-lifecycle.md +++ b/Client-server-discovery-lifecycle.md @@ -72,3 +72,47 @@ The sbt launcher provides a locking facility. fail: port = start new process; write(f, port) } ``` + + +## Proposal 3: A combination of the above. + +Here's a more concrete proposal of how launching a server would work. However, first, let's make some assumptions that are potentially contentious that lead to the following proposal: + +1. the sbt launcher's locking mechanism is sufficient for us to find a means to avoid double-server-startup. +2. We want clients to have *one* means of attempting to fork the sbt server process. +*TODO - more here* + +We create a new interface for the sbt launcher, called `xsbt.ServerMain`: + +```java +package xsbti; + +public interface ServerMain { + public ServerPort[] start(AppConfiguration configuration); + public boolean isAlive(ServerPort[] ports); +} +``` + +The interface has two methods. One responsible for starting the Server, and another which can be used to check whether or not another server is alive, based on a given set of server port connections. The sbt launcher is responsible for: + +1. Obtaining the lock file for the CWD + AppConfiguratoin-hash pairing. (That is there can only be one server of a given configuration (organization + module id) in any working directory). +2. Reading the ServerPorts from the active configuration. +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: + +```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. +