mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-11-13 18:40:33 +00:00
complete startup module
This commit is contained in:
@@ -2,31 +2,35 @@ package dev.inmo.micro_utils.startup.launcher
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.kslog.common.i
|
||||
import dev.inmo.micro_utils.startup.plugin.ServerPlugin
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
import dev.inmo.micro_utils.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import org.koin.core.KoinApplication
|
||||
import org.koin.core.context.GlobalContext
|
||||
import org.koin.dsl.module
|
||||
import java.io.File
|
||||
|
||||
package dev.inmo.micro_utils.startup.launcher
|
||||
|
||||
import dev.inmo.
|
||||
|
||||
class ServerLauncher : ServerPlugin {
|
||||
val defaultJson = Json {
|
||||
ignoreUnknownKeys = true
|
||||
}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
|
||||
KSLog.default = KSLog("PlaguBot")
|
||||
KSLog.default = KSLog("ServerLauncher")
|
||||
val (configPath) = args
|
||||
val file = File(configPath)
|
||||
KSLog.i("Start read config from ${file.absolutePath}")
|
||||
val json = defaultJson.parseToJsonElement(file.readText()).jsonObject
|
||||
KSLog.i("Config has been read")
|
||||
|
||||
ServerLauncher.start().join()
|
||||
with(StartupLauncher) {
|
||||
logger.i("Start initialization")
|
||||
val koinApp = KoinApplication.init()
|
||||
koinApp.modules(
|
||||
module {
|
||||
setupDI(json)
|
||||
}
|
||||
)
|
||||
logger.i("Modules loaded")
|
||||
GlobalContext.startKoin(koinApp)
|
||||
logger.i("Koin started")
|
||||
startPlugin(koinApp.koin)
|
||||
logger.i("Behaviour builder has been setup")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user