Fix service reload

This commit is contained in:
世界
2023-10-10 08:00:00 +08:00
parent 141eff8841
commit cb06973881
4 changed files with 11 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ import io.nekohasekai.sfa.database.ProfileManager
import io.nekohasekai.sfa.database.Settings
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
@@ -117,7 +118,7 @@ class BoxService(
this.commandServer = commandServer
}
private suspend fun startService() {
private suspend fun startService(delayStart: Boolean = false) {
try {
val selectedProfileId = Settings.selectedProfile
if (selectedProfileId == -1L) {
@@ -154,6 +155,10 @@ class BoxService(
return
}
if (delayStart) {
delay(200L)
}
newService.start()
boxService = newService
commandServer?.setService(boxService)
@@ -182,7 +187,7 @@ class BoxService(
Seq.destroyRef(refnum)
}
boxService = null
startService()
startService(true)
}
}