Skip to content

Commit

Permalink
moved wrapper watcher into an thread
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoMarlir committed May 18, 2024
1 parent 9ef3dbf commit 516ecf3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class Wrapper: AbstractSystemPart(InternalSystemPartType.WRAPPER) {

private fun postStart() {
logger.info("Starting Wrapper...")
WrapperWatcher.instance.start()
WrapperWatcher.instance.initialize()
while (true) {
Thread.sleep(50000)
}
}

private fun setupFileStructure() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@ package me.blueamethyst.bluecloud.wrapper.logic
import me.blueamethyst.bluecloud.wrapper.Wrapper.Companion.logger
import java.io.Closeable

class WrapperWatcher: Closeable {
class WrapperWatcher: Thread("wrapper-watcher"), Closeable {
var running = false; private set

fun start() {
init {
isDaemon = true
}

fun initialize() {
logger.info("Starting WrapperWatcher")
running = true
spin()
start()
}

private fun spin() {
while (running) {

//TODO: check if service is in the queue
sleep(1000)
}
}

override fun close() {
logger.info("Closed WrapperWatcher")
running = false
interrupt()
logger.info("Closed WrapperWatcher")
}

companion object {
val instance = WrapperWatcher()
}

override fun run() {
spin()
}
}

0 comments on commit 516ecf3

Please sign in to comment.