0

I'm writing a program in Node.js which sends a WhatsApp template every day at a specific time. I used node-cron and setInterval. When I deployed the program on https://dashboard.render.com/# or https://id.heroku.com/login to run it remotely it doesn't work. but when I run it locally on VSCode it works fine, I can't seem to figure out the issue.

Help is appreciated.

const express = require('express');
const webApp = express();

webApp.use(express.json());
const PORT = process.env.PORT;
function myFunc() {
    // console.log("Checking every 2 second")
    cron.schedule('15 16 * * *', () => {
        console.log("Checking every 2 second")
        sendDayTemplate();

    })
}
setTimeout(myFunc, 1000);

webApp.listen(PORT, () => {
    console.log(`Server is up and running at ${PORT}`);
});


Heroku logs Render logs

Dummy Cron
  • 143
  • 2
  • 11
  • Do you have error logs from heroku.? You can find by following https://devcenter.heroku.com/articles/logging Also heroku servers are shut if here is no traffic. That could be reason. – manpreet May 13 '22 at 11:54
  • Yes, I have attached the logs in the edited question. Is there a way I can keep the server running? – Dummy Cron May 13 '22 at 12:00
  • This could be of help - https://stackoverflow.com/questions/39057883/heroku-and-node-cron – manpreet May 13 '22 at 12:12
  • One of the answers suggested to keep the pinging the server, is that good practice? if yes, any suggested method I should implement? Thank you for your assistance! – Dummy Cron May 13 '22 at 12:42
  • I believe using heroku scheduler will be better option than ping system – manpreet May 16 '22 at 10:48

0 Answers0