class BootServerSocket extends AutoCloseable
A BootServerSocket is used for remote clients to connect to sbt for io while sbt is still loading the build. There are two scenarios in which this functionality is needed:
1. client a starts an sbt server and then client b tries to connect to the server before the server has loaded. Presently, client b will try to start a new server even though there is one booting. This can cause a java process leak because the second server launched by client b is unable to create a server because there is an existing portfile by the time it starts up.
2. a remote client initiates a reboot command. Reboot causes sbt to shutdown the server which makes the client disconnect. Since sbt does not start the server until the project has successfully loaded, there is no way for the client to see the output of the server. This is particularly problematic if loading fails because the server will be stuck waiting for input that will not be forthcoming.
To address these issues, the BootServerSocket can be used to immediately create a server socket before sbt even starts loading the build. It works by creating a local socket either in project/target/SOCK_NAME or a windows named pipe with name SOCK_NAME where SOCK_NAME is computed as the hash of the project's base directory (for disambiguation in the windows case). If the server can't create a server socket because there is already one running, it either prompts the user if they want to start a new server even if there is already one running if there is a console available or exits with the status code 2 which indicates that there is another sbt process starting up.
Once the server socket is created, it listens for new client connections. When a client connects, the server will forward its input and output to the client via Terminal.setBootStreams which updates the Terminal.proxyOutputStream to forward all bytes written to the BootServerSocket's outputStream which in turn writes the output to each of the connected clients. Input is handed similarly.
When the server finishes loading, it closes the boot server socket.
BootServerSocket is implemented in java so that it can be classloaded as quickly as possible.
- Alphabetic
- By Inheritance
- BootServerSocket
- AutoCloseable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new BootServerSocket(configuration: AppConfiguration)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
close(): Unit
- Definition Classes
- BootServerSocket → AutoCloseable
- Annotations
- @SuppressWarnings() @Override()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def inputStream(): InputStream
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def outputStream(): OutputStream
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()