Small refactor...

This commit is contained in:
BurnyLlama 2021-11-01 18:12:46 +01:00
parent c4df7a735a
commit 0cbd14018e
2 changed files with 9 additions and 5 deletions

View File

@ -5,14 +5,14 @@ import initLog from '../utils/log.js'
export let sqlite = undefined
export let skinDB = undefined
const log = initLog("DB Init")
const log = initLog("Database")
/**
* This initalizes the ddnet.sqlite and skindata.sqlite DB...
* @module db/dbInit
*/
export function dbInit() {
console.log("Starting up databases...")
log("Starting up databases...")
/* load in db using better-sqlite3 */
sqlite = new Database('ddnet.sqlite', { verbose: console.log });
@ -24,6 +24,6 @@ export function dbInit() {
/* Unsafe mode */
sqlite.unsafeMode()
log("Loaded in ddnet.sqlite...")
log("Loaded in skindata.sqlite...")
log("Loaded in 'ddnet.sqlite'!")
log("Loaded in 'skindata.sqlite'!")
}

View File

@ -9,6 +9,8 @@ export async function ddnssStart() {
const getServers = await fetch('https://ddnet.tw/status/index.json');
const servers = await getServers.json();
log(`Found ${servers.length} online servers!`)
for (const server of servers) {
const connection = `${server.ip}:${server.port}`
@ -25,11 +27,13 @@ export async function ddnssStart() {
await scrapeServer(`${connection}`)
}
// PLEASE!!
exec(`pkill -9 -f ddnss`)
}
function scrapeServer(server) {
// TODO: Maybe fix the paths to be dynamic? Or have some sort of buildscript...
// -- BurnyLlama
const command = `./ddnss/build/DDNet "ui_server_address ${server}" -f ddnss/build/config.conf`
return new Promise((resolve, reject) => {