Heroku and node-cron?

后端 未结 3 1073
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 02:21

So I know Heroku\'s free dynos \'wind down\' when there isn\'t any traffic to them– how would this effect the cron jobs that I\'ve implemented using the node-cron module?

相关标签:
3条回答
  • 2021-02-02 02:56

    I think you can create a ping system that keeps Heroku running every 10 mins. So if your cron job is scheduled to run every month. It would not go to sleep due to the ping. You may need to verify your credit card to obtain more free units so that you don't run out of hrs for that month

    0 讨论(0)
  • 2021-02-02 03:08

    Jobs scheduled by node_cron won't run when your free dynos are sleeping.

    As an alternative, you can use the Heroku Scheduler add-on to schedule your cron jobs. That will trigger one-off dynos to run your cron jobs. Provided you don't exceed your monthly allowance of free dyno hours, you will be able to run your cron jobs for free.

    0 讨论(0)
  • 2021-02-02 03:23

    Probably they won't work as you expect in 100%. I mean, if cron execution will be scheduled at the time when your server would be offline, then it won't work. Hobby Dynos on Heroku power-up only at HTTP request and shutdown after some period of inactivity, they won't boot because of cron.

    0 讨论(0)
提交回复
热议问题