Update NCCli.scala
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 5b9bcc3..3531d3a 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
@@ -405,7 +405,6 @@
// Store mapping file between PID and timestamp (once we have server PID).
// Note that the same timestamp is used in server log file.
ignoring(classOf[IOException]) {
- // TODO: These don't get deleted?
new File(SystemUtils.getUserHome, s".nlpcraft/.pid_${srvPid}_tstamp_$logTstamp").createNewFile()
}
@@ -546,6 +545,21 @@
throw new IllegalStateException(s"Classpath not found: ${c(path)}")
/**
+ *
+ */
+ private def cleanUpTempFiles(): Unit = {
+ val tstamp = currentTime - 1000 * 60 * 60 * 24 * 2 // 2 days ago.
+
+ for (file <- new File(SystemUtils.getUserHome, ".nlpcraft").listFiles())
+ if (file.lastModified() < tstamp) {
+ val name = file.getName
+
+ if (name.startsWith("server_log") || name.startsWith("server_log") || name.startsWith(".pid_"))
+ file.delete()
+ }
+ }
+
+ /**
* @param cmd Command descriptor.
* @param args Arguments, if any, for this command.
* @param repl Whether or not running from REPL.
@@ -2987,6 +3001,8 @@
sys.exit(exitStatus)
}
+ cleanUpTempFiles()
+
// Boot up.
boot(args)
}