-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed multithreading for the sake of my own sanity rn
- Loading branch information
1 parent
34fbe46
commit 7db7839
Showing
6 changed files
with
138 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,13 @@ | ||
import { spawn } from "child_process"; | ||
import getDB from "./db"; | ||
|
||
export function secondsToMs(d: number) { | ||
return d * 1000; | ||
} | ||
|
||
// threading should happen at top level of server "setInterval" | ||
async function checkDB(TIMEOUT: number): Promise<boolean> { | ||
return new Promise((resolve, reject) => { | ||
let dbAval: boolean = false; | ||
|
||
const database = spawn("bun", ["dbCheck.ts", TIMEOUT.toString()]); | ||
|
||
database.stdout.on("data", (data) => { | ||
console.log("Output from dbCheck.ts:", data.toString()); | ||
}); | ||
|
||
database.on("exit", (code) => { | ||
if (code === 0) { | ||
dbAval = true; | ||
} else { | ||
dbAval = false; | ||
} | ||
resolve(dbAval); | ||
}); | ||
async function checkDB(){ | ||
const db = await getDB(); | ||
|
||
database.on("error", (error) => { | ||
console.error(error); | ||
reject(error); | ||
}); | ||
}); | ||
if(db) { | ||
await db.end(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export default checkDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters