Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
How cancel scheduled jobs using BreeJS

I have an express server that starts a reoccurring job upon client request for a specified amount of time, the issue I'm facing is: How can I stop and remove that specific job after completion.

The code that I have is

// do the request logic
// generate the job ID
// save the job ID with repetition amount in mongoose
bree.add({
    name: jobID,
    interval : "30s",
    path : "./jobs/example_job.js",
    worker: {
    workerData: {
        jobID: jobID,
        }},
    })
bree.start(jobID)

and for the example_job.js

const thread = require("worker_threads") // for the jobID

// performs some logic
// reduce repetition amount
if(module.repetitionAmout == 0)
{
// delete the mongoose module
// stop the function with name jobID
}

My issue is with // stop the function with name jobID. how can I achieve that? I've tried process.exit(0) but that only exits the thread and doesn't stop it from repeating again I've also tried exporting and importing the bree instance to the example_job.js and passing the jobID to cancel it there but that also did not work, anyone has any experience with canceling jobs?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda