Adjustments
This commit is contained in:
parent
422971a914
commit
ac4f79ff7a
@ -51,6 +51,7 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
||||
val watchDirectories = SharedConfig.incomingContent
|
||||
val queue = FileWatcherQueue()
|
||||
|
||||
@Volatile
|
||||
private var isStopping: Boolean = false
|
||||
@PreDestroy
|
||||
fun setStop() {
|
||||
@ -86,8 +87,10 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
||||
private suspend fun startWatchOnDirectory(file: File) {
|
||||
if (activeWatchers.any {it -> it.file.absolutePath == file.absolutePath}) {
|
||||
log.error { "Attempting to start a watcher on an already watched directory ${file.absolutePath}" }
|
||||
return
|
||||
}
|
||||
val watcher = file.asWatcher { watcher ->
|
||||
try {
|
||||
watcher.consumeEach {
|
||||
if (it.file == SharedConfig.incomingContent) {
|
||||
logger.info { "IO Watcher ${it.kind} on ${it.file.absolutePath}" }
|
||||
@ -109,6 +112,11 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
log.error { "Consume failed ${e.message}" }
|
||||
e.printStackTrace()
|
||||
watcher.close()
|
||||
}
|
||||
}.also { watcher ->
|
||||
watcher.watcher.invokeOnClose {
|
||||
it?.printStackTrace()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user