mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-11-01 06:55:06 +01:00
correct spelling
This commit is contained in:
parent
b7fe56687c
commit
37eeef06e2
@ -13,9 +13,6 @@ import okhttp3.OkHttpClient
|
|||||||
import okhttp3.Request.Builder
|
import okhttp3.Request.Builder
|
||||||
import suwayomi.tachidesk.server.impl.AboutDataClass
|
import suwayomi.tachidesk.server.impl.AboutDataClass
|
||||||
import suwayomi.tachidesk.server.serverConfig
|
import suwayomi.tachidesk.server.serverConfig
|
||||||
import suwayomi.tachidesk.server.util.AppMutex.AppMutexStat.Clear
|
|
||||||
import suwayomi.tachidesk.server.util.AppMutex.AppMutexStat.OtherApplicationRunning
|
|
||||||
import suwayomi.tachidesk.server.util.AppMutex.AppMutexStat.TachideskInstanceRunning
|
|
||||||
import suwayomi.tachidesk.server.util.Browser.openInBrowser
|
import suwayomi.tachidesk.server.util.Browser.openInBrowser
|
||||||
import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedAnotherAppRunning
|
import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedAnotherAppRunning
|
||||||
import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedTachideskRunning
|
import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedTachideskRunning
|
||||||
@ -25,7 +22,7 @@ import java.util.concurrent.TimeUnit
|
|||||||
object AppMutex {
|
object AppMutex {
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
private enum class AppMutexStat(val stat: Int) {
|
private enum class AppMutexState(val stat: Int) {
|
||||||
Clear(0),
|
Clear(0),
|
||||||
TachideskInstanceRunning(1),
|
TachideskInstanceRunning(1),
|
||||||
OtherApplicationRunning(2)
|
OtherApplicationRunning(2)
|
||||||
@ -33,7 +30,7 @@ object AppMutex {
|
|||||||
|
|
||||||
private val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip
|
private val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip
|
||||||
|
|
||||||
private fun checkAppMutex(): AppMutexStat {
|
private fun checkAppMutex(): AppMutexState {
|
||||||
val client = OkHttpClient.Builder()
|
val client = OkHttpClient.Builder()
|
||||||
.connectTimeout(200, TimeUnit.MILLISECONDS)
|
.connectTimeout(200, TimeUnit.MILLISECONDS)
|
||||||
.build()
|
.build()
|
||||||
@ -45,23 +42,23 @@ object AppMutex {
|
|||||||
val response = try {
|
val response = try {
|
||||||
client.newCall(request).execute().use { response -> response.body!!.string() }
|
client.newCall(request).execute().use { response -> response.body!!.string() }
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
return AppMutexStat.Clear
|
return AppMutexState.Clear
|
||||||
}
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
JavalinJackson.fromJson(response, AboutDataClass::class.java)
|
JavalinJackson.fromJson(response, AboutDataClass::class.java)
|
||||||
AppMutexStat.TachideskInstanceRunning
|
AppMutexState.TachideskInstanceRunning
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
AppMutexStat.OtherApplicationRunning
|
AppMutexState.OtherApplicationRunning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleAppMutex() {
|
fun handleAppMutex() {
|
||||||
when (checkAppMutex()) {
|
when (checkAppMutex()) {
|
||||||
Clear -> {
|
AppMutexState.Clear -> {
|
||||||
logger.info("Mutex status is clear, Resuming startup.")
|
logger.info("Mutex status is clear, Resuming startup.")
|
||||||
}
|
}
|
||||||
TachideskInstanceRunning -> {
|
AppMutexState.TachideskInstanceRunning -> {
|
||||||
logger.info("Another instance of Tachidesk is running on $appIP:${serverConfig.port}")
|
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.")
|
logger.info("Probably user thought tachidesk is closed so, opening webUI in browser again.")
|
||||||
@ -71,7 +68,7 @@ object AppMutex {
|
|||||||
|
|
||||||
shutdownApp(MutexCheckFailedTachideskRunning)
|
shutdownApp(MutexCheckFailedTachideskRunning)
|
||||||
}
|
}
|
||||||
OtherApplicationRunning -> {
|
AppMutexState.OtherApplicationRunning -> {
|
||||||
logger.error("A non Tachidesk application is running on $appIP:${serverConfig.port}, aborting startup.")
|
logger.error("A non Tachidesk application is running on $appIP:${serverConfig.port}, aborting startup.")
|
||||||
shutdownApp(MutexCheckFailedAnotherAppRunning)
|
shutdownApp(MutexCheckFailedAnotherAppRunning)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user