feat: Add CLI

This commit is contained in:
oSumAtrIX
2024-01-29 03:46:17 +01:00
parent 9999b242ad
commit a988ffbd23
10 changed files with 107 additions and 33 deletions

View File

@@ -0,0 +1,39 @@
package app.revanced.api.command
import app.revanced.api.plugins.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import picocli.CommandLine
@CommandLine.Command(
name = "start",
description = ["Start the API server"],
)
internal object StartAPICommand : Runnable {
@CommandLine.Option(
names = ["-h", "--host"],
description = ["The host address to bind to."],
)
private var host: String = "0.0.0.0"
@CommandLine.Option(
names = ["-p", "--port"],
description = ["The port to listen on."],
)
private var port: Int = 8080
override fun run() {
embeddedServer(Netty, port, host, configure = {
connectionGroupSize = 1
workerGroupSize = 1
callGroupSize = 1
}) {
configureHTTP()
configureSerialization()
configureDatabases()
configureSecurity()
configureDependencies()
configureRouting()
}.start(wait = true)
}
}