heroku-buildpack-meteor
heroku-buildpack-meteor copied to clipboard
heroku scheduler with node.js file
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();
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/
Also you could use something like the SyncedCron package to run scheduled tasks inside of a meteor app.