This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-13
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-13 by this push:
new 8e1a81b Improved embedded probe shutdown.
8e1a81b is described below
commit 8e1a81bee1839c8a7478eb4e940728e5004feb12
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Mon Mar 16 19:43:55 2020 -0700
Improved embedded probe shutdown.
---
.../org/apache/nlpcraft/probe/NCProbeBoot.scala | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
b/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
index dd43a45..a81cbbb 100644
--- a/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
+++ b/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
@@ -61,6 +61,7 @@ private [probe] object NCProbeBoot extends LazyLogging with
NCOpenCensusTrace {
@volatile private var started = false
@volatile private var shutdownHook: Thread = _
+ @volatile private var probeThread: Thread = _
// This container designed only for internal usage (transfer common data
between methods).
private case class ProbeConfig(
@@ -163,6 +164,8 @@ private [probe] object NCProbeBoot extends LazyLogging with
NCOpenCensusTrace {
* @param fut
*/
private def start0(cfg: ProbeConfig, fut: CompletableFuture[Void]): Unit =
{
+ probeThread = Thread.currentThread()
+
asciiLogo()
ackConfig(cfg)
@@ -189,10 +192,15 @@ private [probe] object NCProbeBoot extends LazyLogging
with NCOpenCensusTrace {
fut.complete(null)
// Wait indefinitely.
- ignoring(classOf[InterruptedException]) {
- Thread.currentThread().join()
- }
+ while (started)
+ try
+ Thread.currentThread().join()
+ catch {
+ case _: InterruptedException ⇒ ()
+ }
}
+
+ logger.info("Embedded probe thread stopped OK.")
}
/**
@@ -207,6 +215,11 @@ private [probe] object NCProbeBoot extends LazyLogging
with NCOpenCensusTrace {
}
started = false
+
+ if (probeThread != null)
+ probeThread.interrupt()
+
+ logger.info("Embedded probe shutdown OK.")
}
/**
@@ -332,7 +345,7 @@ private [probe] object NCProbeBoot extends LazyLogging with
NCOpenCensusTrace {
raw" / /| / / /_/ / /___/ / / /_/ / __/ /_ $NL" +
raw"/_/ |_/_/ .___/\____/_/ \__,_/_/ \__/ $NL" +
raw" /_/ $NL$NL" +
- s"Data Probe$NL" +
+ s"Embedded Data Probe$NL" +
s"Version: ${ver.version}$NL" +
raw"${NCVersion.copyright}$NL"