0

I have a cron running and wanna know what ways I have to release new version of it without impacting any execution of the cron while deploying the changes. I am using node-cron library (but my question is agnostic of the underlying library tbh) and the cron is doing a couple of calls to gather data from DB, call an endpoint and update some rows. How can I make sure a deploy of a newer version of this cron doesn't kill the process right before updating all the tables?

I have checked other resources online but couldn't find anything really useful as they mention changing the execution plan of the cron before deployment. This would work, but it is too intrusive for my taste. I would want to have the option to setup this in a deployment script or something similar and I want some guidance how to do that

  • Why do you think changing the cron job would kill the process? – jabaa Jan 24 '23 at 18:02
  • With a new version of the cron released, the old one will be stopped and the new version will be started. Correct? So if the current cron is in the middle of an execution, won't the release impact its execution by stopping the cron in the middle of it? – Tintareanu George Jan 24 '23 at 18:05
  • 1
    _"With a new version of the cron released, the old one will be stopped and the new version will be started. Correct? "_ No, that's not correct. It's not a service. Cron starts a process and won't stop it, even when you delete the job. Cron isn't able to stop it. – jabaa Jan 24 '23 at 18:06
  • node-cron has cron style timings (thats all) its not system cron. In node everything is memory you can install the new package version, do changes and whatnot and only after restarting the process will it take effect – Lawrence Cherone Jan 24 '23 at 18:15
  • Ok, I think I get what you mean. You're saying when the business logic changes that will not impact the current execution of the process since once a process is started (being it is with the old version of the code) it will be completed and not be impacted by the new code version – Tintareanu George Jan 24 '23 at 18:17
  • 1
    I'm only talking about cron, not node-cron because the question is tagged with cron. I don't know how node-cron works. After cron started a job, you can modify or delete it in the cron tab. – jabaa Jan 24 '23 at 18:17
  • Cool. Thanks for your help! It's more clear to me now and I have to test some stuff to confirm I got it right – Tintareanu George Jan 24 '23 at 18:19

0 Answers0