This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-108
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-108 by this push:
new aac9de1 Update NCCli.scala
aac9de1 is described below
commit aac9de15c457c0721cb79b4ee6ff7328a5dd5abf
Author: Aaron Radzinski <[email protected]>
AuthorDate: Thu Oct 1 23:37:27 2020 -0700
Update NCCli.scala
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index ad55edb..a05f046 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -199,7 +199,7 @@ object NCCli extends App {
id = "get-server",
names = Seq("get-server"),
synopsis = s"Basic information about locally running REST server.",
- body = cmdServerInfo
+ body = cmdGetServer
),
Command(
id = "no-ansi",
@@ -429,13 +429,18 @@ object NCCli extends App {
val igniteCfgPath = args.find(_.parameter.id == "igniteConfig")
val noWait = args.exists(_.parameter.id == "noWait")
val output = args.find(_.parameter.id == "output") match {
- case Some(arg) ⇒ new File(arg.value.get)
+ case Some(arg) ⇒ new File(stripQuotes(arg.value.get))
case None ⇒ new File(SystemUtils.getUserHome,
s".nlpcraft/server-output-$currentTime.txt")
}
checkFilePath(cfgPath)
checkFilePath(igniteCfgPath)
+ loadServerBeacon() match {
+ case Some((b, _)) ⇒ throw new IllegalStateException(s"Existing
local server (pid ${c(b.pid)}) detected.")
+ case None ⇒ ()
+ }
+
val pb = new ProcessBuilder(
JAVA,
"-ea",
@@ -506,8 +511,8 @@ object NCCli extends App {
error(s"Check output for errors:
${c(output.getAbsolutePath)}")
}
else {
- logln()
- logln(s"Server has
started:\n${mkServerBeaconTable(beacon)}")
+ logln(g("[OK]"))
+ logln(mkServerBeaconTable(beacon).toString)
}
}
@@ -594,8 +599,9 @@ object NCCli extends App {
i += 1
- // Pause between pings.
- Thread.sleep(1000)
+ if (i < num)
+ // Pause between pings.
+ Thread.sleep(1000)
}
}
@@ -635,9 +641,9 @@ object NCCli extends App {
val pid = beacon.pid
if (ph.destroy())
- logln(s"Local REST server (pid ${c(pid.toString)}) has
been stopped.")
+ logln(s"Local REST server (pid ${c(pid)}) has been
stopped.")
else
- error(s"Failed to stop the local REST server (pid
${c(pid.toString)}).")
+ error(s"Failed to stop the local REST server (pid
${c(pid)}).")
case None ⇒
error("Cannot detect locally running REST server.")
@@ -813,7 +819,7 @@ object NCCli extends App {
* @param args Arguments, if any, for this command.
* @param repl Whether or not executing from REPL.
*/
- private def cmdServerInfo(cmd: Command, args: Seq[Argument], repl:
Boolean): Unit = {
+ private def cmdGetServer(cmd: Command, args: Seq[Argument], repl:
Boolean): Unit = {
loadServerBeacon() match {
case Some((beacon, _)) ⇒ logln(s"Local REST
server:\n${mkServerBeaconTable(beacon).toString}")
case None ⇒ error(s"Cannot detect local REST server.")
@@ -1157,9 +1163,6 @@ object NCCli extends App {
else
doCommand(args.toSeq, repl = false)
- if (IS_SCRIPT)
- logln()
-
sys.exit(exitStatus)
}