2020-06-22 17:02:36 +00:00
|
|
|
/*
|
|
|
|
Mangadex@Home
|
|
|
|
Copyright (c) 2020, MangaDex Network
|
|
|
|
This file is part of MangaDex@Home.
|
|
|
|
|
|
|
|
MangaDex@Home 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.
|
|
|
|
|
|
|
|
MangaDex@Home 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this MangaDex@Home. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-06-19 20:16:24 +00:00
|
|
|
package mdnet.base
|
|
|
|
|
2020-06-20 16:32:15 +00:00
|
|
|
import ch.qos.logback.classic.LoggerContext
|
2020-06-19 20:16:24 +00:00
|
|
|
import kotlin.system.exitProcess
|
2020-07-04 19:00:59 +00:00
|
|
|
import mdnet.BuildInfo
|
2020-07-02 16:06:32 +00:00
|
|
|
import org.slf4j.LoggerFactory
|
2020-06-19 20:16:24 +00:00
|
|
|
|
|
|
|
object Main {
|
|
|
|
private val LOGGER = LoggerFactory.getLogger(Main::class.java)
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
fun main(args: Array<String>) {
|
|
|
|
println(
|
2020-07-04 19:00:59 +00:00
|
|
|
"Mangadex@Home Client Version ${BuildInfo.VERSION} (Build ${Constants.CLIENT_BUILD}) initializing"
|
2020-06-19 20:16:24 +00:00
|
|
|
)
|
2020-06-22 17:02:36 +00:00
|
|
|
println()
|
2020-06-19 20:16:24 +00:00
|
|
|
println("Copyright (c) 2020, MangaDex Network")
|
2020-06-22 17:02:36 +00:00
|
|
|
println("""
|
|
|
|
Mangadex@Home 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.
|
2020-06-22 17:09:11 +00:00
|
|
|
|
2020-06-22 17:02:36 +00:00
|
|
|
Mangadex@Home 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 General Public License for more details.
|
2020-06-22 17:09:11 +00:00
|
|
|
|
2020-06-22 17:02:36 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Mangadex@Home. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
""".trimIndent())
|
2020-06-19 20:16:24 +00:00
|
|
|
|
|
|
|
var file = "settings.json"
|
|
|
|
if (args.size == 1) {
|
|
|
|
file = args[0]
|
|
|
|
} else if (args.isNotEmpty()) {
|
|
|
|
dieWithError("Expected one argument: path to config file, or nothing")
|
|
|
|
}
|
|
|
|
|
2020-07-20 04:22:13 +00:00
|
|
|
val client = MangaDexClient(file)
|
2020-06-19 20:16:24 +00:00
|
|
|
Runtime.getRuntime().addShutdownHook(Thread { client.shutdown() })
|
|
|
|
client.runLoop()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun dieWithError(e: Throwable): Nothing {
|
2020-07-04 19:39:11 +00:00
|
|
|
LOGGER.error(e) { "Critical Error" }
|
2020-06-20 16:32:15 +00:00
|
|
|
(LoggerFactory.getILoggerFactory() as LoggerContext).stop()
|
2020-06-19 20:16:24 +00:00
|
|
|
exitProcess(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun dieWithError(error: String): Nothing {
|
2020-07-04 19:39:11 +00:00
|
|
|
LOGGER.error { "Critical Error: $error" }
|
|
|
|
|
2020-06-20 16:32:15 +00:00
|
|
|
(LoggerFactory.getILoggerFactory() as LoggerContext).stop()
|
2020-06-19 20:16:24 +00:00
|
|
|
exitProcess(1)
|
|
|
|
}
|
|
|
|
}
|