Using Heroku Scheduler with Node.js

前端 未结 6 1446
小蘑菇
小蘑菇 2020-12-07 11:14

There is literally no tutorial about using Heroku Scheduler with Node.js. Assume that I have a function called sayHello() and I would like to run it every 10 mins. Ho

6条回答
  •  北海茫月
    2020-12-07 11:24

    A better approach is to define your schedule file called for example worker.js with following content:

    function sayHello() {
        console.log('Hello');
    }
    sayHello();
    

    and then in the heroku schedule, you just write node worker like you define it in the Procfile and that's all!

提交回复
热议问题