Fix engine
Some checks failed
PRs & Pushes / test (push) Failing after 1m46s
PRs & Pushes / build-jars (push) Failing after 1m59s
PRs & Pushes / build-apidoc (push) Failing after 3m25s

This commit is contained in:
JeremyStar™ 2024-12-29 05:03:16 +01:00
parent 36da65b45e
commit a1e843f61e
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
3 changed files with 122 additions and 13 deletions

View file

@ -22,11 +22,13 @@ package de.staropensource.engine.base
import de.staropensource.engine.base.exception.EngineInitializationFailureException
import de.staropensource.engine.base.implementable.Subsystem
import de.staropensource.engine.base.logging.Logger
import de.staropensource.engine.base.platform.platformEngineBootstrap
import de.staropensource.engine.base.platform.platformEngineInitialize
import de.staropensource.engine.base.platform.platformEngineReload
import de.staropensource.engine.base.platform.platformEngineShutdown
import de.staropensource.engine.base.utility.Environment
import de.staropensource.engine.base.utility.FileAccess
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
import kotlin.jvm.JvmStatic
import kotlin.reflect.KClass
@ -186,9 +188,7 @@ class Engine private constructor() {
logger.info("Bootstrapping")
// Run bootstrapping code
// -> Run checks
if (Charset.defaultCharset() != StandardCharsets.UTF_8)
logger.crash("The StarOpenSource Engine does not support other charsets than UTF-8")
platformEngineBootstrap()
// Bootstrap subsystems
logger.verb("Bootstrapping subsystems")
@ -243,6 +243,7 @@ class Engine private constructor() {
logger.info("Initializing")
// Run initialization code
platformEngineInitialize()
Environment.detect()
FileAccess.updateDefaultPaths()
info = BuildInformation(loadPrefix = "sosengine-base")
@ -303,7 +304,7 @@ class Engine private constructor() {
logger.info("Reloading")
// Run reload code
// *none yet*
platformEngineReload()
// Reload subsystems
logger.verb("Reloading subsystems")
@ -399,13 +400,7 @@ class Engine private constructor() {
state = State.SHUTTING_DOWN
val infoLocal: BuildInformation? = info
// Run shutdown code
Environment.unset()
FileAccess.deleteScheduled()
FileAccess.unsetDefaultPaths()
info = null
// Initialize subsystems
// Shut subsystems down
logger.verb("Shutting subsystems down")
for (subsystem: Subsystem in subsystems) {
val subsystemVersion: String = subsystem.getVersion()
@ -422,6 +417,13 @@ class Engine private constructor() {
}
}
// Run shutdown code
Environment.unset()
FileAccess.deleteScheduled()
FileAccess.unsetDefaultPaths()
info = null
platformEngineShutdown(final, crashed)
// Print shutdown message
if (final)
logger.info("""

View file

@ -0,0 +1,70 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU General Public License v3.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.platform
import de.staropensource.engine.base.Engine
/**
* Bootstraps this platform.
*
* Invoked by [Engine.bootstrap] first.
*
* @throws Throwable on error
* @since v1-alpha10
*/
@Throws(Throwable::class)
expect fun platformEngineBootstrap()
/**
* Initializes this platform.
*
* Invoked by [Engine.initialize] first.
*
* @throws Throwable on error
* @since v1-alpha10
*/
@Throws(Throwable::class)
expect fun platformEngineInitialize()
/**
* Reloads this platform.
*
* Invoked by [Engine.reload] first.
*
* @throws Throwable on error
* @since v1-alpha10
*/
@Throws(Throwable::class)
expect fun platformEngineReload()
/**
* Shuts this platform down.
*
* Invoked by one of the
* engine's shutdown methods
* last.
*
* @param final whether this is the last time the engine shuts down. Doesn't actually shut the application down, just changes some messages and does other things
* @param crashed enables super careful mode to prevent further breakage
* @throws Throwable on error
* @since v1-alpha10
*/
@Throws(Throwable::class)
expect fun platformEngineShutdown(final: Boolean, crashed: Boolean = false)

View file

@ -0,0 +1,37 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU General Public License v3.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.platform
import de.staropensource.engine.base.Engine.Companion.logger
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
@Throws(Throwable::class)
actual fun platformEngineBootstrap() {
if (Charset.defaultCharset() != StandardCharsets.UTF_8)
logger.crash("The StarOpenSource Engine does not support other charsets than UTF-8")
}
@Throws(Throwable::class)
actual fun platformEngineInitialize() = Unit
@Throws(Throwable::class)
actual fun platformEngineReload() = Unit
@Throws(Throwable::class)
actual fun platformEngineShutdown(final: Boolean, crashed: Boolean) = Unit