Merge pull request #6999 from eed3si9n/bport/6994

[1.8.x] add output when boot server socket fails to create
This commit is contained in:
eugene yokota 2022-08-10 20:46:47 -04:00 committed by GitHub
commit e05acf9ca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 6 deletions

View File

@ -141,23 +141,31 @@ private[sbt] object xMain {
private def getSocketOrExit(
configuration: xsbti.AppConfiguration
): (Option[BootServerSocket], Option[Exit]) =
try (Some(new BootServerSocket(configuration)) -> None)
): (Option[BootServerSocket], Option[Exit]) = {
def printThrowable(e: Throwable): Unit = {
println("sbt thinks that server is already booting because of this exception:")
e.printStackTrace()
}
try Some(new BootServerSocket(configuration)) -> None
catch {
case e: ServerAlreadyBootingException
if System.console != null && !ITerminal.startedByRemoteClient =>
println("sbt thinks that server is already booting because of this exception:")
e.printStackTrace()
printThrowable(e)
println("Create a new server? y/n (default y)")
val exit =
if (ITerminal.get.withRawInput(System.in.read) == 'n'.toInt) Some(Exit(1))
else None
(None, exit)
case _: ServerAlreadyBootingException =>
case e: ServerAlreadyBootingException =>
if (SysProp.forceServerStart) (None, None)
else (None, Some(Exit(2)))
else {
printThrowable(e)
(None, Some(Exit(2)))
}
case _: UnsatisfiedLinkError => (None, None)
}
}
}
final class ScriptMain extends xsbti.AppMain {