mirror of https://github.com/sbt/sbt.git
One issue with the remote client approach is that it is possible for multiple clients to start multiple servers concurrently. I encountered this in testing where in one tmux pane I'd start an sbt server and in another I might run sbtc before the server had finished loading. This can actually cause java processes to leak because the second process is unable to start a server but it doesn't necessarily die after the client that spawned it exits. This commit prevents this scenario by creating a server socket before it loads the build and closes once the build is complete. The client can then receive output bytes and forward input to the booting server. The socket that is created during boot is always a local socket, either a UnixDomainServerSocket or a Win32NamedPipeServerSocket. At the moment, I don't see any reason to support TCP. This socket also has no impact at all on the normal sbt server that is started up after the project has loaded. The socket is hardcoded to be located at the relative path project/target/$SOCK_NAME or the named pipe $SOCK_NAME where SOCK_NAME is a farm hash of the absolute path of the project base directory. There is no portfile json since there is no need since we don't support TCP. After the socket is created it listens for clients to whom it relays input to the console's input stream and relays the process output back to the client. See the javadoc in BootServerSocket.java for further details. The process for forking the server is also a bit more complicated after this change because the client will read the process output and error streams until the socket is created and thereafter will only read output from the socket, not the process. |
||
|---|---|---|
| .. | ||
| src/main/scala/sbt/scriptedtest | ||
| NOTICE | ||