Skip to content

Commit

Permalink
generacion de preguntas cada x minutos sin bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bidof committed Mar 11, 2024
1 parent 051307d commit 953350d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions questionservice/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ class Scheduler {
console.error(error);
}
}

start() {
cron.schedule('*/30 * * * *', async () => {
cron.schedule('*/15 * * * *', async () => {

try {
await this.addQuestion();
} catch (error) {
console.error('Failed to add question:', error);
// Aquí podrías implementar una lógica para manejar el error, como reintentar después de un tiempo,
// enviar una alerta, etc.
}


/* version con errores
this.success = false;
while (!this.success) {
//ojo como es asincrono si no lo pones el bucle se sigue ejecutando y petas la pila de javasycrpit y cae el contendor
await this.addQuestion();
}
*/
});
}
}
Expand Down

0 comments on commit 953350d

Please sign in to comment.