3

I made a small web service using Node.js and PhantomJS, and deployed it to Google app engine using its flexible environments... The problem is, the service is used only for half an hour each day, but the VM instances is running all time and I pay for that... So I need to be automatically able to start the instance(s) before scheduled run time of my app, and then automatically stop them I tried use Cron jobs to call start/stop via the API, as in here, but it failed..

Thanks for advance

1 Answers1

4

We don't seem to currently expose the version stop method in the rest API: https://cloud.google.com/appengine/docs/admin-api/

However - you can stop a version by running this command:

gcloud app versions list
gcloud app versions stop <version>

That will make sure the VMs get shut down. When you're ready to turn them back on...

gcloud app versions start <version>

Hope this helps!

Justin Beckwith
  • 7,686
  • 1
  • 33
  • 55
  • Hi Justin, thanks for your reply, I've stopped the instance automatically using another app engine python app, using googleapiclient package, unfortunately, the instance start automatically after about 5 minutes, do you have any idea about the reason ??.. Thanks again – ahmadelmorshedy Jul 31 '16 at 09:29
  • You can't use the instance commands like that :). Instances are always starting and stopping during the lifecycle of an app engine application. If you want to stop the app, you have to stop the versions. I'll check out why the version API isn't public on monday, but for now the gcloud command is probably the best bet. – Justin Beckwith Jul 31 '16 at 17:06
  • 1
    Good news! I chatted with another engineer on the team, and it turns out you /can/ do this with the API. Update the servingStatus with this API: https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions/patch – Justin Beckwith Aug 01 '16 at 21:43
  • Thanks Justin, I'm currently working in another task, but will return to this issue further, thank you very much :) – ahmadelmorshedy Aug 04 '16 at 11:46