On Apigee SAAS, deployed a nodejs hosted target to support cron tasks. This app used node-cron libraries. The started cron task run once every 10 minutes.The task dies after a while, no discernible pattern , sometimes it runs for an hour or so , and other times much longer.
This nodejs app runs without any of these issues & runs as expected when run locally(on a windows or unix machine).
Steps -
1. Request is sent to proxy with hosted target to schedule and start cron task.
2. At intervals, the task kicks off and send a request to export apigee analytics data to a Big Query database.
3. Then the response is sent to stackdriver logs in GCP.
Any ideas on what may be happening with the NodeJS hosted target ?
Hosted Targets scale down to zero after periods of inactivity (https://docs.apigee.com/api-platform/hosted-targets/hosted-targets-reference#scaling), ie: when no request has been received for a period of time.
If you're already using GCP I suggest you use Cloud Scheduler to kick off your request to export analytics data