Skip to content

Commit

Permalink
Abandon Terminating Language Server (#1463)
Browse files Browse the repository at this point in the history
Wait for the LS shutdown, spawn the new one,
and only then reply to the client.
  • Loading branch information
4e6 authored and iamrecursion committed Feb 15, 2021
1 parent eed6f43 commit 074ca72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class LanguageServerController(
case ServerDied =>
log.error(s"Language server died [$connectionInfo]")
context.stop(self)

}

private def removeClient(
Expand Down Expand Up @@ -278,8 +279,9 @@ class LanguageServerController(
maybeRequester.foreach(_ ! ServerShutdownTimedOut)
stop()

case StartServer(_, _, _, _) =>
sender() ! PreviousInstanceNotShutDown
case m: StartServer =>
// This instance has not yet been shut down. Retry
context.parent.forward(Retry(m))
}

private def waitingForChildren(): Receive = { case Terminated(_) =>
Expand Down Expand Up @@ -349,18 +351,17 @@ object LanguageServerController {

case object ShutDownServer

/** Signals boot timeout.
*/
/** Signals boot timeout. */
case object BootTimeout

/** Boot command.
*/
/** Boot command. */
case object Boot

/** Signals shutdown timeout.
*/
/** Signals shutdown timeout. */
case object ShutdownTimeout

case object ServerDied

case class Retry(message: Any)

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.enso.projectmanager.boot.configuration.{
SupervisionConfig,
TimeoutConfig
}
import org.enso.projectmanager.infrastructure.languageserver.LanguageServerController.Retry
import org.enso.projectmanager.infrastructure.languageserver.LanguageServerProtocol.{
CheckIfServerIsRunning,
KillThemAll,
Expand All @@ -23,6 +24,8 @@ import org.enso.projectmanager.service.LoggingServiceDescriptor
import org.enso.projectmanager.util.UnhandledLogging
import org.enso.projectmanager.versionmanagement.DistributionConfiguration

import scala.concurrent.duration._

/** An actor that routes request regarding lang. server lifecycle to the
* right controller that manages the server.
* It creates a controller actor, if a server doesn't exist.
Expand Down Expand Up @@ -112,6 +115,11 @@ class LanguageServerRegistry(
case CheckIfServerIsRunning(projectId) =>
sender() ! serverControllers.contains(projectId)

case Retry(message) =>
context.system.scheduler.scheduleOnce(200.millis, self, message)(
context.dispatcher,
context.sender()
)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import org.enso.runtimeversionmanager.distribution.{
DistributionManager,
TemporaryDirectoryManager
}
import org.enso.runtimeversionmanager.locking.{FileLockManager, ResourceManager}
import org.enso.runtimeversionmanager.locking.{
ResourceManager,
ThreadSafeFileLockManager
}
import org.enso.runtimeversionmanager.releases.ReleaseProvider
import org.enso.runtimeversionmanager.releases.engine.{
EngineRelease,
Expand All @@ -38,7 +41,9 @@ object DefaultDistributionConfiguration
lazy val distributionManager = new DistributionManager(environment)

/** @inheritdoc */
lazy val lockManager = new FileLockManager(distributionManager.paths.locks)
lazy val lockManager = new ThreadSafeFileLockManager(
distributionManager.paths.locks
)

/** @inheritdoc */
lazy val resourceManager = new ResourceManager(lockManager)
Expand Down

0 comments on commit 074ca72

Please sign in to comment.