fix: WebService 启动崩溃与关闭卡顿
This commit is contained in:
@@ -169,7 +169,9 @@ class WebService : BaseService() {
|
|||||||
postEvent(EventBus.WEB_SERVICE, hostAddress)
|
postEvent(EventBus.WEB_SERVICE, hostAddress)
|
||||||
FlowEventBus.post(EventBus.WEB_SERVICE, hostAddress)
|
FlowEventBus.post(EventBus.WEB_SERVICE, hostAddress)
|
||||||
startForegroundNotification()
|
startForegroundNotification()
|
||||||
} catch (e: IOException) {
|
} catch (e: Exception) {
|
||||||
|
ktorServer?.stop()
|
||||||
|
ktorServer = null
|
||||||
toastOnUi(e.localizedMessage ?: "")
|
toastOnUi(e.localizedMessage ?: "")
|
||||||
e.printOnDebug()
|
e.printOnDebug()
|
||||||
stopSelf()
|
stopSelf()
|
||||||
|
|||||||
@@ -165,8 +165,8 @@ class KtorServer(private val port: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
server?.stop(1000, 1000)
|
server?.stop(0, 0)
|
||||||
wsServer?.stop(1000, 1000)
|
wsServer?.stop(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun PipelineContext<Unit, ApplicationCall>.handlePost(
|
private suspend fun PipelineContext<Unit, ApplicationCall>.handlePost(
|
||||||
|
|||||||
Reference in New Issue
Block a user