简体   繁体   中英

Cron job for Google Appengine Endpoints

I like to add cron job for Google Appengine Endpoints.

But in the document for the Endpoints mentioned that we cant add cron job for the GAE Endpoint.

From Document: You cannot call a Google Cloud Endpoint directly from a push task queue or a cron job. GAE Endpoint Source: https://cloud.google.com/appengine/docs/java/endpoints/

Is there a way to add cron job for the endpoint?

Cron Source: https://cloud.google.com/appengine/docs/java/config/cron

You'll need to split the logic from your endpoint method out into a separate function or class.

You can then call that separate function/class from both a standard servlet AND the endpoints handler - this way both the servlet and the endpoint call the exact same code.

Then, in your web.xml you'll need to make sure that the URL for the servlet that will be called by cron is only accessible to admin users, then in your cron config you just tell cron to call the admin-protected URL.

Bit of a faff but works.

Does your cron need to call one of your Endpoints method ? If yes, you need to put the method's code in a separate task (or a separate webapp2 handler), which can then be called by both the cron and the Endpoints method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM