Small refactor...
This commit is contained in:
parent
c4df7a735a
commit
0cbd14018e
|
@ -5,14 +5,14 @@ import initLog from '../utils/log.js'
|
||||||
export let sqlite = undefined
|
export let sqlite = undefined
|
||||||
export let skinDB = undefined
|
export let skinDB = undefined
|
||||||
|
|
||||||
const log = initLog("DB Init")
|
const log = initLog("Database")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This initalizes the ddnet.sqlite and skindata.sqlite DB...
|
* This initalizes the ddnet.sqlite and skindata.sqlite DB...
|
||||||
* @module db/dbInit
|
* @module db/dbInit
|
||||||
*/
|
*/
|
||||||
export function dbInit() {
|
export function dbInit() {
|
||||||
console.log("Starting up databases...")
|
log("Starting up databases...")
|
||||||
|
|
||||||
/* load in db using better-sqlite3 */
|
/* load in db using better-sqlite3 */
|
||||||
sqlite = new Database('ddnet.sqlite', { verbose: console.log });
|
sqlite = new Database('ddnet.sqlite', { verbose: console.log });
|
||||||
|
@ -24,6 +24,6 @@ export function dbInit() {
|
||||||
/* Unsafe mode */
|
/* Unsafe mode */
|
||||||
sqlite.unsafeMode()
|
sqlite.unsafeMode()
|
||||||
|
|
||||||
log("Loaded in ddnet.sqlite...")
|
log("Loaded in 'ddnet.sqlite'!")
|
||||||
log("Loaded in skindata.sqlite...")
|
log("Loaded in 'skindata.sqlite'!")
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ export async function ddnssStart() {
|
||||||
const getServers = await fetch('https://ddnet.tw/status/index.json');
|
const getServers = await fetch('https://ddnet.tw/status/index.json');
|
||||||
const servers = await getServers.json();
|
const servers = await getServers.json();
|
||||||
|
|
||||||
|
log(`Found ${servers.length} online servers!`)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const connection = `${server.ip}:${server.port}`
|
const connection = `${server.ip}:${server.port}`
|
||||||
|
|
||||||
|
@ -25,11 +27,13 @@ export async function ddnssStart() {
|
||||||
await scrapeServer(`${connection}`)
|
await scrapeServer(`${connection}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PLEASE!!
|
||||||
exec(`pkill -9 -f ddnss`)
|
exec(`pkill -9 -f ddnss`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrapeServer(server) {
|
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`
|
const command = `./ddnss/build/DDNet "ui_server_address ${server}" -f ddnss/build/config.conf`
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user