Long running script in Google Cloud

2019-09-18 19:49发布

问题:

I have a piece of code, based on NodeJs, that does not serve any HTTP request, but monitors some online systems and sends report emails. This code is run by a shell script and keeps running 24x7.

Which Google Cloud offering is best suited to host this?

I tried with App Engine, but after one hour of console inactivity, the console exists and the script stops running.

I am not sure if Compute Engine would be best for this. I can host this in AWS EC2, it would work there... but wondering about Google.

Any tips appreciated.

Thanks

回答1:

This can be done with a simple Python app running in App Engine Standard Platform. See this post for details.



回答2:

If you're able to modify it so it can run periodically you could run it on AWS Lambda with a schedule as trigger and use SES to send out e-mails.

Alternatively, if you have control over the "online systems", you could use CloudWatch custom metrics and create alerts based on the thresholds of your metrics.

If you must use Google Cloud, you could use Google Cloud Functions instead of AWS Lambda, and Google Cloud Monitoring / Logging.