Packages

c

sbt.internal

BootServerSocket

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.

Linear Supertypes
AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BootServerSocket
  2. AutoCloseable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BootServerSocket(configuration: AppConfiguration)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. def close(): Unit
    Definition Classes
    BootServerSocket → AutoCloseable
    Annotations
    @SuppressWarnings() @Override()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def inputStream(): InputStream
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. def outputStream(): OutputStream
  18. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped