0

I am trying to create an app using node, in which users can schedule certain cron jobs ,the setting for these job I am fetching from the users and saving it to mongoDB .I need my app to be such that users can start stop these jobs whenever they want . I have a class created which is something like this

Class Croncreator {
    constructor () {Creates the cron job}
    startCron ()
    stropCron()}

Now all this is working ,but I cannot wrap my head around how do I manage this in a multi user environment? Do I create an instance of this class in my express route for "/api/savecronjob" ,if yes then how do I manage the start stop feature .Considering the fact that 1 user may be creating multiple jobs a time and switching them on off when ever he wants.

Renato Gama
  • 16,431
  • 12
  • 58
  • 92
Tanmay Bhattacharya
  • 551
  • 1
  • 5
  • 16

1 Answers1

0

I solved the problem by using a NPM package called cron-job-manager. Read more about it NPM LINK The documentation is pretty self explanatory .

I basically created a function to create the cron jobs with a identifier,and created two routes to start and stop these jobs.

Tanmay Bhattacharya
  • 551
  • 1
  • 5
  • 16