我已经指定了一个cron作业(在开发中测试),但它似乎没有运行.如何确保工作在生产中有效?
cron.yaml:
cron:
- description: cron test gathering
url: /test/cron
schedule: every 2 minutes from 09:00 to 23:00
Run Code Online (Sandbox Code Playgroud)
app.yaml中:
application: cron_test
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: main.py
Run Code Online (Sandbox Code Playgroud)
main.py:
url_map = [ ('/test/cron', test.CronHandler),
('/error', err.Err404Handler)]
application = webapp.WSGIApplication(url_map, debug=False)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
FeedCron定义为:
class CronHandler(webapp.RequestHandler):
def get(self):
logging.info("NOTE: CronHandler get request");
return None
Run Code Online (Sandbox Code Playgroud)
我期待在应用引擎的日志中看到"请注意:CronHandler获取请求"这一行.我正在使用GoogleAppEngineLauncher应用程序(版本:1.5.3.1187)来启动和停止应用程序.
噢!刚刚看到SDK文档中的细则:
使用 Python SDK 时,dev_appserver 有一个管理界面,允许您在 /_ah/admin/cron 处查看 cron 作业。
开发服务器不会自动运行您的 cron 作业。您可以使用本地桌面的 cron 或计划任务界面,通过curl 或类似工具触发作业的 URL。
| 归档时间: |
|
| 查看次数: |
3381 次 |
| 最近记录: |