mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
restart workers on error
This commit is contained in:
parent
0259cfe1a7
commit
16cd4d9d4b
4 changed files with 57 additions and 14 deletions
|
@ -693,8 +693,18 @@ function handleWorkerData() {
|
|||
}: { workerIndex: number; initData: Array<QuestionDb> } = workerData
|
||||
let qdbs: Array<QuestionDb> = initData
|
||||
|
||||
const subjCount = initData.length
|
||||
const questionCount = initData.reduce((qCount, qdb) => {
|
||||
return (
|
||||
qCount +
|
||||
qdb.data.reduce((sCount, subject) => {
|
||||
return sCount + subject.Questions.length
|
||||
}, 0)
|
||||
)
|
||||
}, 0)
|
||||
|
||||
logger.Log(
|
||||
`[THREAD #${workerIndex}]: Worker ${workerIndex} reporting for duty`
|
||||
`[THREAD #${workerIndex}]: Worker ${workerIndex} reporting for duty! subjects: ${subjCount}, questions: ${questionCount}`
|
||||
)
|
||||
|
||||
parentPort.on('message', async (msg /*: TaskObject */) => {
|
||||
|
@ -936,6 +946,7 @@ export function cleanDb(
|
|||
return recievedQuestions.map(() => [])
|
||||
}
|
||||
|
||||
// FIXME: compare images & data too!
|
||||
const questionIndexesToRemove = recievedQuestions.map((recievedQuestion) =>
|
||||
qdbs[qdbIndex].data[subjIndex].Questions.reduce<number[]>(
|
||||
(acc, question, i) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue