Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda