Is it possible to spawn another cron job derived from this parent cron job as in this scenario as I do not see any examples in doc.
SyncedCron.add({
name: ‘Cron job HTTP get from external API’,
schedule: function(parser) {
return parser.text(‘every 15 seconds’);
},
job: function(intendedAt) {
Meteor.call(‘getServiceA’, ‘userName’, function (err, respJson) {
if (err) {
console.log("Reason of error is : ", err.reason);
} else {
console.log("respJson: ", respJson);
}
});
Meteor.call('postServiceB');
console.log('job should be running at:');
console.log('intendedAt :' ,intendedAt);
}
});
Meteor.startup(() => {
Meteor.methods({
getServiceA: function (userName) {
const nextOneDay = moment().add(1, 'days').unix();
const url = 'http://mysite.com/&start_date=", EJSON.stringify(nextOneDay )";
var result = HTTP.call('GET', url, {}, function (err, resp) {
// How to start a list of one time future child SyncedCron jobs,
‘postServiceB’ with time information extracted from getServiceA result like
// i.e
postServiceB 20 mins from extracted time 2016-04-13 10:10:00
postServiceB 60 mins from extracted time 2016-04-15 10:50:00
postServiceB 80 mins from extracted time 2016-04-16 20:10:00
etc
Or do you do another SyncedCron.start() in parent cron job (getServiceA) to start child cron job?
Here shows how to fire one time job, but not sure how to structure this as a child job
var newCronJobId = Meteor.uuid();
SyncedCron.add({
name: newCronJobId,
schedule: function (parser) {
return parser.text(‘after 20 secs’);
},
job: function () {
SyncedCron.remove(newCronJobId);
// do stuff
}
});