|
1 | 1 | package app.ryss.gateway
|
2 | 2 |
|
3 | 3 | import app.ryss.gateway.core.GatewayService
|
| 4 | +import ch.qos.logback.classic.Level |
| 5 | +import ch.qos.logback.classic.Logger |
4 | 6 | import io.ktor.server.engine.embeddedServer
|
5 | 7 | import io.ktor.server.netty.Netty
|
6 | 8 | import io.sentry.Sentry
|
7 |
| -import kotlinx.cli.ArgParser |
8 |
| -import kotlinx.cli.ArgType |
9 |
| -import kotlinx.cli.default |
10 | 9 | import org.slf4j.LoggerFactory
|
11 |
| -import ch.qos.logback.classic.Logger |
12 |
| -import ch.qos.logback.classic.Level |
13 |
| -import org.slf4j.event.Level as SLF4JLevel |
14 | 10 |
|
15 | 11 | /**
|
16 |
| - * Application main entry point. |
| 12 | + * Gateway entry point. |
17 | 13 | */
|
18 |
| -fun main(args: Array<String>) { |
19 |
| - val parser = ArgParser("gateway") |
20 |
| - val debug by parser.option(ArgType.Boolean, shortName = "d", fullName = "debug", description = "Enables debug mode") |
21 |
| - .default(false) |
22 |
| - val logLevel by parser.option( |
23 |
| - ArgType.Choice(SLF4JLevel.values().map(Any::toString)), |
24 |
| - shortName = "ll", |
25 |
| - fullName = "log-level", |
26 |
| - description = "Sets the log level" |
27 |
| - ).default("INFO") |
28 |
| - val enableGraphiQL by parser.option(ArgType.Boolean, shortName = "giql", fullName = "graphiql", description = "Enabled graphiql").default(false) |
29 |
| - parser.parse(args) |
| 14 | +fun main() { |
| 15 | + val debug = System.getenv("ENVIRONMENT") == "DEVELOPMENT" |
| 16 | + val logLevel = Level.valueOf(System.getenv("GATEWAY_SERVICE_LOG_LEVEL")) |
| 17 | + val enableGraphiQL = System.getenv("GATEWAY_SERVICE_ENABLE_GRAPHQL") == "true" |
30 | 18 |
|
31 | 19 | val rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger
|
32 |
| - rootLogger.level = Level.valueOf(logLevel) |
| 20 | + rootLogger.level = logLevel |
33 | 21 |
|
34 | 22 | if (!debug) {
|
35 | 23 | Sentry.init(
|
36 |
| - "${System.getenv("GATEWAY_SERVICE_SENTRY_DSN")}?stacktrace" + |
37 |
| - ".app.packages=app.ryss" |
| 24 | + "${System.getenv("GATEWAY_SERVICE_SENTRY_DSN")}?stacktrace.app.packages=app.ryss" |
38 | 25 | )
|
39 | 26 | } else {
|
40 | 27 | Sentry.init()
|
|
0 commit comments