简体   繁体   English

有没有一种方法可以运行Google App引擎的cron任务,而不用碰到端点,而是将cron.yaml指向python脚本?

[英]Is there a way to run a Google App engine cron task without hitting an endpoint but rather pointing cron.yaml at a python script?

my end goal is to update Google cloud storage with some json data and I would rather it run a script rather than hitting a url endpoint. 我的最终目标是使用一些json数据更新Google云存储,我希望它运行脚本而不是访问url端点。 What would be the proper configuration of cron.yaml if, let's say the script were to sit right next to app.yaml? 如果假设脚本位于app.yaml旁边,那么cron.yaml的正确配置是什么?

A cron job in GAE has to hit a URL, there's no other way to do it. GAE中的Cron工作必须命中URL,没有其他方法可以做到。 That's just how the system is designed. 这就是系统的设计方式。

But since you have control over app.yaml anyway, you can easily assign your script to a URL there. 但是由于仍然可以控制app.yaml,因此可以轻松地将脚本分配给该URL。

From the documentation : 文档中

You cannot call a Google Cloud Endpoint from a cron job. 您无法通过cron作业调用Google Cloud Endpoint。 Instead, you should issue a request to a target that is served by a handler that's specified in your app's configuration file or in a dispatch file. 相反,您应该向由应用程序的配置文件或调度文件中指定的处理程序服务的目标发出请求。 That handler then calls the appropriate endpoint class and method. 然后,该处理程序将调用适当的终结点类和方法。

However (from the same documentation), 但是(根据同一文档)

A cron job will invoke a URL, using an HTTP GET request, at a given time of day. cron作业将在一天的给定时间使用HTTP GET请求调用URL。 An HTTP request invoked by cron can run for up to 10 minutes, but is subject to the same limits as other HTTP requests. cron调用的HTTP请求最多可以运行10分钟,但与其他HTTP请求的限制相同。

If you set up the Routing in main.py to use a script right next to it and app.yaml, it would be called. 如果在main.py “路由”设置为在脚本和app.yaml旁边使用脚本,则会调用该脚本。 If that's what you call an endpoint, then that's what gets called. 如果这就是您所说的端点,那么那就是所谓的端点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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