Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
820 B
26 lines
820 B
4 years ago
|
package dev.openrs2.archive
|
||
|
|
||
|
import dev.openrs2.db.Database
|
||
|
import dev.openrs2.db.PostgresDeadlockDetector
|
||
|
import javax.inject.Provider
|
||
|
import org.flywaydb.core.Flyway
|
||
|
import org.postgresql.ds.PGSimpleDataSource
|
||
|
|
||
|
public class DatabaseProvider : Provider<Database> {
|
||
|
override fun get(): Database {
|
||
|
val dataSource = PGSimpleDataSource()
|
||
|
// TODO(gpe): make the URL configurable
|
||
|
dataSource.setUrl("jdbc:postgresql://localhost/runearchive?user=gpe&password=gpe")
|
||
|
|
||
|
Flyway.configure()
|
||
|
.dataSource(dataSource)
|
||
|
.locations("classpath:/dev/openrs2/archive")
|
||
|
.load()
|
||
|
.migrate()
|
||
|
|
||
|
// TODO(gpe): wrap dataSource with HikariCP? how do we close the pool?
|
||
|
|
||
|
return Database(dataSource, deadlockDetector = PostgresDeadlockDetector)
|
||
|
}
|
||
|
}
|