heroku-buildpack-meteor icon indicating copy to clipboard operation
heroku-buildpack-meteor copied to clipboard

heroku scheduler with node.js file

Open dhavaln opened this issue 9 years ago • 2 comments

So I want to run a periodic job with Heroku Scheduler but the job fails every time with following message.

ReferenceError: require is not defined`

This is the code I am running in scheduler file schedulerTest:

var http = require('http');

var options = {
    host: 'sometesturl.herokuapp.com',
    port: 80,
    path: '/api/schedulertest',
    method: 'GET'
};

http.request(options, function(res) {
        res.on('data', function (chunk) {
            console.log('BODY: ' + chunk);
        });
}).end();

dhavaln avatar Dec 22 '15 08:12 dhavaln

Is this inside of a Meteor App? If so, you should not have to require anything as the http module is already included in Meteor Core. Take a look at this post by the Meteor Chef: https://themeteorchef.com/snippets/using-the-http-package/

rfines avatar Jan 22 '16 19:01 rfines

Also you could use something like the SyncedCron package to run scheduled tasks inside of a meteor app.

rfines avatar Jan 22 '16 19:01 rfines