mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-03-09 18:42:00 +01:00
handle when the user runs the app instead of clicking on systemtray
This commit is contained in:
parent
326da504ea
commit
e2c4b4cb57
@ -1,7 +1,10 @@
|
|||||||
package ir.armor.tachidesk.server.util
|
package ir.armor.tachidesk.server.util
|
||||||
|
|
||||||
|
import mu.KotlinLogging
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
enum class ExitCode(val code: Int) {
|
enum class ExitCode(val code: Int) {
|
||||||
Success(0),
|
Success(0),
|
||||||
MutexCheckFailedTachideskRunning(1),
|
MutexCheckFailedTachideskRunning(1),
|
||||||
@ -9,5 +12,7 @@ enum class ExitCode(val code: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun shutdownApp(exitCode: ExitCode) {
|
fun shutdownApp(exitCode: ExitCode) {
|
||||||
|
logger.info("Shutting Down Tachidesk. Goodbye!")
|
||||||
|
|
||||||
exitProcess(exitCode.code)
|
exitProcess(exitCode.code)
|
||||||
}
|
}
|
||||||
|
@ -59,11 +59,17 @@ object AppMutex {
|
|||||||
logger.info("Mutex status is clear, Resuming startup.")
|
logger.info("Mutex status is clear, Resuming startup.")
|
||||||
}
|
}
|
||||||
TachideskInstanceRunning -> {
|
TachideskInstanceRunning -> {
|
||||||
logger.info("Another instance of Tachidesk is running on $appIP:${serverConfig.port}, Aborting.")
|
logger.info("Another instance of Tachidesk is running on $appIP:${serverConfig.port}")
|
||||||
|
|
||||||
|
logger.info("Probably user thought tachidesk is closed so, opening webUI in browser again.")
|
||||||
|
openInBrowser()
|
||||||
|
|
||||||
|
logger.info("Aborting startup.")
|
||||||
|
|
||||||
shutdownApp(ExitCode.MutexCheckFailedTachideskRunning)
|
shutdownApp(ExitCode.MutexCheckFailedTachideskRunning)
|
||||||
}
|
}
|
||||||
OtherApplicationRunning -> {
|
OtherApplicationRunning -> {
|
||||||
logger.error("A non Tachidesk application is running on $appIP:${serverConfig.port}, Aborting.")
|
logger.error("A non Tachidesk application is running on $appIP:${serverConfig.port}, aborting startup.")
|
||||||
shutdownApp(ExitCode.MutexCheckFailedAnotherAppRunning)
|
shutdownApp(ExitCode.MutexCheckFailedAnotherAppRunning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user