minor changes
This commit is contained in:
@@ -31,6 +31,7 @@ dependencies {
|
||||
implementation 'io.github.microutils:kotlin-logging-jvm:3.0.5'
|
||||
implementation "io.ktor:ktor-network:3.4.2"
|
||||
implementation "io.github.oshai:kotlin-logging-jvm:7.0.3"
|
||||
implementation 'io.github.cdimascio:dotenv-java:3.0.0'
|
||||
implementation "org.slf4j:slf4j-api:2.0.13"
|
||||
implementation "ch.qos.logback:logback-classic:1.5.20"
|
||||
implementation "io.fusionauth:fusionauth-jwt:6.0.0"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
25
|
||||
30
|
||||
0
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,7 @@ import database.Repository
|
||||
import mu.KotlinLogging
|
||||
import network.NetworkManager
|
||||
import runner.CommandInvoker
|
||||
import java.io.File
|
||||
import io.github.cdimascio.dotenv.Dotenv
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
@@ -64,32 +64,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
private fun loadDotEnv() {
|
||||
val envFile = File(".env")
|
||||
if (!envFile.exists()) {
|
||||
logger.warn { ".env not found, using system env vars" }
|
||||
return
|
||||
}
|
||||
envFile.forEachLine { line ->
|
||||
val trimmed = line.trim()
|
||||
if (trimmed.isEmpty() || trimmed.startsWith("#")) return@forEachLine
|
||||
val idx = trimmed.indexOf('=')
|
||||
if (idx == -1) return@forEachLine
|
||||
val key = trimmed.substring(0, idx).trim()
|
||||
val value = trimmed.substring(idx + 1).trim().removeSurrounding("\"").removeSurrounding("'")
|
||||
setEnv(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun setEnv(key: String, value: String) {
|
||||
try {
|
||||
val processEnv = System.getenv()::class.java
|
||||
val field = processEnv.getDeclaredField("m")
|
||||
field.isAccessible = true
|
||||
(field.get(System.getenv()) as MutableMap<String, String>)[key] = value
|
||||
} catch (_: Exception) {
|
||||
System.setProperty(key, value)
|
||||
}
|
||||
Dotenv.configure().systemProperties().ignoreIfMissing().load()
|
||||
}
|
||||
|
||||
fun registerServerCommands(
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.time.ZoneOffset
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
class JWTManager (
|
||||
private val jwtSecret: String = System.getenv("JWT_SECRET") ?: error("JWT_SECRET not set"),
|
||||
private val jwtSecret: String = System.getenv("JWT_SECRET") ?: System.getProperty("JWT_SECRET") ?: error("JWT_SECRET not set"),
|
||||
private val issuer: String = "aklivtsov.tech",
|
||||
) {
|
||||
private val signer: Signer = HMACSigner.newSHA256Signer(jwtSecret)
|
||||
|
||||
@@ -14,10 +14,10 @@ class DatabaseManager {
|
||||
|
||||
fun start() {
|
||||
val config = HikariConfig().apply {
|
||||
jdbcUrl = System.getenv("DB_URL") ?: "jdbc:postgresql://localhost:5432/prog7_db"
|
||||
jdbcUrl = System.getenv("DB_URL") ?: System.getProperty("DB_URL") ?: "jdbc:postgresql://localhost:5432/prog7_db"
|
||||
driverClassName = "org.postgresql.Driver"
|
||||
username = System.getenv("DB_USER") ?: error("DB_USER not set")
|
||||
password = System.getenv("DB_PASS") ?: error("DB_PASS not set")
|
||||
username = System.getenv("DB_USER") ?: System.getProperty("DB_USER") ?: error("DB_USER not set")
|
||||
password = System.getenv("DB_PASS") ?: System.getProperty("DB_PASS") ?: error("DB_PASS not set")
|
||||
maximumPoolSize = 11
|
||||
isAutoCommit = false
|
||||
transactionIsolation = "TRANSACTION_REPEATABLE_READ"
|
||||
|
||||
@@ -27,7 +27,7 @@ class NetworkManager(
|
||||
fun start() {
|
||||
logger.info { "Server started on port $port. Waiting for connection..." }
|
||||
repeat(4) {
|
||||
readerPool.submit(::readLoop)
|
||||
readerPool.submit { readLoop() }
|
||||
}
|
||||
try {
|
||||
Thread.currentThread().join()
|
||||
|
||||
Reference in New Issue
Block a user