Hosted target service if failing to run beyond 15 mins

Hi There,

I have very basic node js app implemented as a hosted target on Apigee cloud. The job of the App is to trigger another API on Apigee once every minute.

The app is deployed successfully and able to trigger the target API once every minute. However after the 15th min the triggers stop. I have tried with a different interval (e.g. 10 sec) even in this the triggers stop after 15 mins after triggering every 10 sec. Wondering if there is some form of rule that kills the node service after 15 mins?

I am attaching the code snippet of the Node module below.

const request = require('request');

var requestLoop = setInterval(function(){
request('https://my-domain.apigee.net/v1/event-handler', { json: true }, (err, res, body) => {
     if(!err && res.statusCode == 200){
          console.log('sucess!');
      }else{
          console.log('error' + res.statusCode);
      }
  });
}, 60000);
0 4 114
4 REPLIES 4

I tried similar stuff using node-cron, here aswell the job stops after running for 15 mins.

Below snippet runs every minute and prints to stderr and stops after the 15th.

cron.schedule("0 * * * * *", function() { 
console.log("running a task every minute"); });

Hosted Targets will scale to 0 if they don't have traffic (after 15 mins IIRC), so they're not really suited to this use case.

Maybe Cloud Scheduler with a HTTP target would work better for you?

https://cloud.google.com/scheduler/docs/creating

I like Christian's answer.... if you just want a thing that runs once per minute, use a tool like cloud scheduler that is designed for that.

On the other hand, if your hosted target really is a wrapper for a different HTTP endpoint, and you just want better control over it, consider converting your "hosted target" to App Engine... and setting the properties on the app to not scale to zero.

Wondering if there is some form of rule that kills the node service after 15 mins?

Yes. Hosted Targets has some particular behaviors that you cannot control. Scaling to 0 is one of them. If you want to control that, you can use a different hosting model that gives you that control. Like App Engine.

Not applicable

I am not sure. But I can assume there would be certain execution time configured in Apigee just like normal JS policy execution time is configured in the policy.