簡體   English   中英

cron為什么會失敗?

[英]Why does cron fail?

所以我有這兩個cron作業(但是從屏幕上可以看到它們失敗了,但是我在日志中看不到任何異常。): Cron失敗

class AddTaskHandler(webapp2.RequestHandler):
def get(self):
    try:
        try:
            logging.info('trying to purge the queue')
            q = taskqueue.Queue('default')
            q.purge()
            logging.info('purge completed')
        except Exception as e:
            logging.error('Error in purging queue, continue., e: ' + e.message)
            pass

        logging.info('adding tasks to queue started')

        taskqueue.add(url = '/tasks/popularityUpdate')
        taskqueue.add(url = '/tasks/weatherUpdate')
        taskqueue.add(url = '/tasks/Recalculation')

        logging.info('adding tasks to queue finished')

        logging.info('Removing items from cache')
        memcache.delete_multi({'news1000', 'events1000', 'music1000', 'movies1000', 'theatre1000'})
        logging.info('Removing items from cache done.')

    except Exception as e:
        logging.error('Exception in adding tasks to the queue, e: ' + e.message)

    self.redirect('/')

路由處理程序:

app = webapp2.WSGIApplication([
    ('/', MainHandler),
    ('/cron/addtask', AddTaskHandler),
    ('/cron/refreshInfo', RefreshHandler),
   ], debug=True)
util.run_wsgi_app(app)

APP.YAML:

application: **********
version: 3
runtime: python27
api_version: 1
threadsafe: no

handlers:
- url: /static
  static_dir: static

- url: /favicon\.ico
  static_files: static/img/favicon.ico
  upload: static/img/favicon\.ico

- url: /humans\.txt
  static_files: static/txt/humans.txt
  upload: static/txt/humans\.txt

- url: /robots\.txt
  static_files: static/txt/robots.txt
  upload: static/txt/robots\.txt

- url: /.*
  script: main.py

- url: /tasks/popularityUpdate
  script: main.py

- url: /tasks/Recalculation
  script: main.py

- url: /tasks/weatherUpdate
  script: main.py

- url: /cron/addtask
  script: main.py

- url: /cron/refreshInfo
  script: main.py

builtins:
- appstats: on

CRON.YAML:

cron:
- description: addTaskToTheQueue
  url: /cron/addtask
  schedule: every 3 hours

- description: refreshInformation
  url: /cron/refreshInfo
  schedule: every 24 hours

所以我的問題是-gae將其顯示為“ 失敗”的原因是什么?

  • 您能否訪問添加到任務隊列的網址(即/ tasks / popularityUpdate)?
  • 當您手動輸入cron作業url時,它是否可以執行預期的操作?
  • 管理控制台中的日志是否沒有顯示任何錯誤(在cron請求中)?
  • 為什么在cron-job處理程序( AddTaskHandler )的末尾有重定向? 嘗試將其刪除。

..弗雷德里克

  1. 您應該將包羅萬象的處理程序(/.*)放在app.yaml中的處理程序部分的末尾。
  2. 在瀏覽器中測試一個基本的/ cron / addTask是否有效?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM