谷歌云app.yaml cron.yaml python脚本不工作,但没有日志 [英] Google cloud app.yaml cron.yaml for python script not working but no log

查看:91
本文介绍了谷歌云app.yaml cron.yaml python脚本不工作,但没有日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Google云的cron以一定的时间间隔运行我的Python脚本。我遵循了 https://cloud.google.com/appengine/中的说明docs / standard / python / config / cron 来设置所有内容,并且任务显示在我的任务队列中用于cron作业,但是当我单击运行时状态说失败。在日志中没有任何东西显示出来(当我点击日志下的View时,它显示没有找到任何条目,所以我不能告诉我在做什么错误。我看了一些类似的问题,似乎我应该使用脚本(scraper.py)与cron.yaml和app.yaml位于同一目录,我的代码如下,任何帮助表示赞赏!

I'm trying to use Google cloud's cron to run my Python script at a time interval. I followed instructions from https://cloud.google.com/appengine/docs/standard/python/config/cron to set up everything and the task shows up in my Task Queue for cron jobs, but when I click run the status says failed. Nothing shows up in the log either (when I click "View" under log it says "no entries found" so I can't tell what I'm doing wrong. I looked at some similar questions and it seems like I should be using more handlers but I'm not sure when handlers are needed. The script (scraper.py) is in the same directory as cron.yaml and app.yaml and my code is below. Any help appreciated!

scraper.py

scraper.py

import requests
from bs4 import BeautifulSoup
import datetime
from firebase.firebase import FirebaseApplication

cron.yaml

cron.yaml

cron:
- description: daily update
  url: /
  schedule: every 24 hours

app.yaml

runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /
  script: scraper.app


推荐答案

您无法运行直接从GAE cron获得像 scraper.py 这样的纯Python脚本,至少不会与它的当前内容。

You can't run a plain python script like your scraper.py directly from the GAE cron, at least not with its current content.

您需要一个基本的GAE应用程序框架,并为该cron作业的URL提供一个处理程序。请记住,GAE cron作业只是您的应用需要处理的该URL的GET请求。该处理程序是您要放置要执行的代码的位置。

You need a basic GAE app skeleton in there, with a handler for the cron job's URL. Remember that the GAE cron job is simply a GET request for that URL, which your app needs to handle. That handler is where you'd place the code you want to be executed.

您可以在 Hello World代码审查

这篇关于谷歌云app.yaml cron.yaml python脚本不工作,但没有日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆