Fixed error caused by stupidity...
This commit is contained in:
parent
505e9a5399
commit
35a14b4362
|
@ -5,10 +5,7 @@ import { open } from 'sqlite'
|
||||||
|
|
||||||
const log = initLog("database")
|
const log = initLog("database")
|
||||||
|
|
||||||
export let sqlite = await open({
|
export let sqlite = undefined
|
||||||
filename: 'ddnet.sqlite',
|
|
||||||
driver: sqlite3.cached.Database
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This initializes both the sqlite db and mongodb.
|
* This initializes both the sqlite db and mongodb.
|
||||||
|
@ -30,7 +27,9 @@ async function init() {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true
|
useUnifiedTopology: true
|
||||||
}
|
}
|
||||||
).then(() => log("Connected to mongodb!"))
|
)
|
||||||
|
|
||||||
|
log("Connected to mongodb!")
|
||||||
}
|
}
|
||||||
|
|
||||||
export default init
|
export default init
|
|
@ -1,5 +1,5 @@
|
||||||
import { randomUUID } from 'crypto'
|
import { randomUUID } from 'crypto'
|
||||||
import { Worker } from 'worker_threads'
|
import { SHARE_ENV, Worker } from 'worker_threads'
|
||||||
import initLog from './log.js'
|
import initLog from './log.js'
|
||||||
|
|
||||||
const log = initLog("Worker Setup")
|
const log = initLog("Worker Setup")
|
||||||
|
@ -26,7 +26,7 @@ function waitForThread() {
|
||||||
|
|
||||||
export function initWorkers(threads) {
|
export function initWorkers(threads) {
|
||||||
for (let i = 0; i < threads; ++i) {
|
for (let i = 0; i < threads; ++i) {
|
||||||
workerFarm.push(new Worker('./libs/utils/multithread/genericWorker.js'))
|
workerFarm.push(new Worker('./libs/utils/multithread/genericWorker.js', { env: SHARE_ENV }))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const i in workerFarm) {
|
for (const i in workerFarm) {
|
||||||
|
|
11
libs/utils/multithread/mongoForWorkes.js
Normal file
11
libs/utils/multithread/mongoForWorkes.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import mongoose from 'mongoose'
|
||||||
|
|
||||||
|
export async function connectMongoose() {
|
||||||
|
await mongoose.connect(
|
||||||
|
process.env.MONGO_URI,
|
||||||
|
{
|
||||||
|
useNewUrlParser: true,
|
||||||
|
useUnifiedTopology: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
import Player from '../../../schemas/Player.js'
|
import Player from '../../../schemas/Player.js'
|
||||||
import init from '../../database/init.js'
|
import { connectMongoose } from './mongoForWorkes.js'
|
||||||
import { config } from 'dotenv'
|
|
||||||
|
|
||||||
config()
|
connectMongoose()
|
||||||
init()
|
|
||||||
|
|
||||||
export function main(data) {
|
export function main(data) {
|
||||||
return new Promise(
|
return new Promise(
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import Player from '../../../schemas/Player.js'
|
import Player from '../../../schemas/Player.js'
|
||||||
import init from '../../database/init.js'
|
import { connectMongoose } from './mongoForWorkes.js'
|
||||||
import { config } from 'dotenv'
|
|
||||||
|
|
||||||
config()
|
connectMongoose()
|
||||||
init()
|
|
||||||
|
|
||||||
export function main(data) {
|
export function main(data) {
|
||||||
return new Promise(
|
return new Promise(
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import Player from '../../../schemas/Player.js'
|
import Player from '../../../schemas/Player.js'
|
||||||
import init from '../../database/init.js'
|
import { connectMongoose } from './mongoForWorkes.js'
|
||||||
import { config } from 'dotenv'
|
|
||||||
|
|
||||||
config()
|
connectMongoose()
|
||||||
init()
|
|
||||||
|
|
||||||
export function main(data) {
|
export function main(data) {
|
||||||
return new Promise(
|
return new Promise(
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import Player from '../../../schemas/Player.js'
|
import Player from '../../../schemas/Player.js'
|
||||||
import init from '../../database/init.js'
|
import { connectMongoose } from './mongoForWorkes.js'
|
||||||
import { config } from 'dotenv'
|
|
||||||
|
|
||||||
config()
|
connectMongoose()
|
||||||
init()
|
|
||||||
|
|
||||||
export function main(data) {
|
export function main(data) {
|
||||||
return new Promise(
|
return new Promise(
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import Player from '../../../schemas/Player.js'
|
import Player from '../../../schemas/Player.js'
|
||||||
import init from '../../database/init.js'
|
import { connectMongoose } from './mongoForWorkes.js'
|
||||||
import { config } from 'dotenv'
|
|
||||||
|
|
||||||
config()
|
connectMongoose()
|
||||||
init()
|
|
||||||
|
|
||||||
export function main(data) {
|
export function main(data) {
|
||||||
return new Promise(
|
return new Promise(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user