Packages

p

sbt

internal

package internal

Type Members

  1. class BootServerSocket extends AutoCloseable

    A BootServerSocket is used for remote clients to connect to sbt for io while sbt is still loading the build.

    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.

  2. abstract class CommandChannel extends AnyRef

    A command channel represents an IO device such as network socket or human that can issue command or listen for some outputs.

    A command channel represents an IO device such as network socket or human that can issue command or listen for some outputs. We can think of a command channel to be an abstraction of the terminal window.

  3. case class ConsolePromptEvent(state: State) extends EventMessage with Product with Serializable
  4. case class ConsoleUnpromptEvent(lastSource: Option[CommandSource]) extends EventMessage with Product with Serializable
  5. class ServerAlreadyBootingException extends Exception

Ungrouped