mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 00:38:56 +00:00
[lsi] check whether the parent process is alive; exit if not
Change-Id: I149f1c6a0a48a589f658af98956b30e2f1f952f7 Signed-off-by: akosyakov <anton.kosyakov@typefox.io>
This commit is contained in:
parent
a17ead7ccf
commit
62f0535ee2
2 changed files with 8 additions and 9 deletions
|
@ -11,12 +11,10 @@ import com.google.inject.Guice
|
|||
import com.google.inject.Inject
|
||||
import io.typefox.lsapi.NotificationMessage
|
||||
import io.typefox.lsapi.services.json.LanguageServerToJsonAdapter
|
||||
import io.typefox.lsapi.services.json.MessageMethods
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.PrintStream
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
|
@ -33,8 +31,6 @@ class ServerLauncher {
|
|||
|
||||
@Inject LanguageServerImpl languageServer
|
||||
|
||||
private final AtomicBoolean hasExitNotification = new AtomicBoolean(false)
|
||||
|
||||
def void start() {
|
||||
val stdin = System.in
|
||||
val stdout = System.out
|
||||
|
@ -46,9 +42,6 @@ class ServerLauncher {
|
|||
if (IS_DEBUG) {
|
||||
println(message)
|
||||
}
|
||||
if (message.method == MessageMethods.EXIT) {
|
||||
hasExitNotification.set(true);
|
||||
}
|
||||
super._doAccept(message)
|
||||
}
|
||||
|
||||
|
@ -75,6 +68,11 @@ class ServerLauncher {
|
|||
super.sendResponseError(responseId, errorMessage, errorCode, errorData)
|
||||
}
|
||||
|
||||
override exit() {
|
||||
System.err.println("Exit notification received. Good Bye!")
|
||||
super.exit()
|
||||
}
|
||||
|
||||
}
|
||||
messageAcceptor.protocol.addErrorListener[p1, p2|
|
||||
p2.printStackTrace(System.err)
|
||||
|
@ -82,10 +80,9 @@ class ServerLauncher {
|
|||
messageAcceptor.connect(stdin, stdout)
|
||||
System.err.println("started.")
|
||||
messageAcceptor.join
|
||||
while (!hasExitNotification.get) {
|
||||
while (true) {
|
||||
Thread.sleep(10_000l)
|
||||
}
|
||||
System.err.println("Exit notification received. Good Bye!")
|
||||
}
|
||||
|
||||
def redirectStandardStreams() {
|
||||
|
|
|
@ -48,6 +48,8 @@ class ServerLauncherTest {
|
|||
rootPath = "."
|
||||
]).get
|
||||
Assert.assertTrue(msg != null)
|
||||
client.shutdown
|
||||
client.exit
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue