Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt -client shutdown should not start the server #4638

Open
klntsky opened this issue Apr 30, 2019 · 1 comment
Open

sbt -client shutdown should not start the server #4638

klntsky opened this issue Apr 30, 2019 · 1 comment

Comments

@klntsky
Copy link

klntsky commented Apr 30, 2019

Executing sbt -client shutdown when the server is not running, results in this:

[info] entering *experimental* thin client - BEEP WHIRR
[info] server was not detected. starting an instance
[info] waiting for the server...
[info] waiting for the server...
[info] waiting for the server...
[info] server found
> shutdown
[success] completed

I think it would be much better if in this particular case the server did not start at all. The user may want to just make sure that the server is stopped. And since all this command does is effectively a no-op when the server is down, such a short-cutting can save some time.

@eed3si9n
Copy link
Member

To a potential contributor, the relevant source is all here - https://github.com/sbt/sbt/blob/v1.3.0-M1/main-command/src/main/scala/sbt/internal/client/NetworkClient.scala

  lazy val connection = init()

  start()

  // Open server connection based on the portfile
  def init(): ServerConnection = {
    val portfile = baseDirectory / "project" / "target" / "active.json"
    if (!portfile.exists) {
      forkServer(portfile)
    }

...

  def start(): Unit = {
    console.appendLog(Level.Info, "entering *experimental* thin client - BEEP WHIRR")
    val _ = connection
    val userCommands = arguments filterNot { cmd =>
      cmd.startsWith("-")
    }
    if (userCommands.isEmpty) shell()
    else batchExecute(userCommands)
  }

Maybe the methods need to be refactored so that connection is passed around as a parameter rather than lazy val.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants