breejs / bree

Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
https://jobscheduler.net
MIT License
2.96k stars 80 forks source link

[discussion] Duplicate job name question #168

Closed owen95t closed 2 years ago

owen95t commented 2 years ago

What would you like to discuss?

After a certain job is ran and successfully exits, when I try to create a new job with the same name, it is telling me that a job with that name already exists. How can that be? I may be missing something?

Checklist

shadowgate15 commented 2 years ago

After a job is run the job is not deleted, only the worker. You could use bree.remove followed by bree.add or just modify bree.configs.jobs and then call bree.start. I would suggest using the first option as bree.add will validate the job.

shadowgate15 commented 2 years ago

https://github.com/breejs/bree/issues/169

When I have time I'll add this function which would make this process easier.

owen95t commented 2 years ago

After a job is run the job is not deleted, only the worker. You could use bree.remove followed by bree.add or just modify bree.configs.jobs and then call bree.start. I would suggest using the first option as bree.add will validate the job.

I see. Thanks I'll use bree.remove for now. But it seems that Bree caches these names as well as it seems to persist. I have no idea what names exists in the cache so is there a location to clear such cache? Or can I just reinstall bree.

shadowgate15 commented 2 years ago

Bree doesn't do any caching. It is just scanning the bree.configs.jobs[].name. You should be able to call bree.config.jobs.map((j) => j.name) to get the list.