2012-04-03 144 views
0

所以我有这两个cron作业(但你可以从他们失败的屏幕看,但我没有看到在日志中的任何异常。): Cron Fail为什么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的原因其显示为失败

回答

0
  • 你可以到达你添加到任务队列(即/任务/普及性更新)的网址吗?
  • 当您手动输入cron作业网址时,它是否按照设想进行操作?
  • 管理控制台中的日志是否显示任何错误(在cron请求上)?
  • 为什么在cron-job处理程序(AddTaskHandler)的最后有一个重定向?尝试删除它。

..fredrik

+0

重定向的东西是问题。 – 2012-04-04 13:06:37

0
  1. 您应该将catch-all处理程序(/.*)放在app.yaml的处理程序部分的末尾。
  2. 在浏览器中测试basic/cron/addTask是否有效?
+0

1.我这样做,但没有帮助。 2.它工作在浏览器中,我被重定向到(/) – 2012-04-04 09:20:32

+0

@LukasŠalkauskas阅读我的更新 – 2012-04-04 10:17:09

+0

3.向下滚动,你会看到路由:) – 2012-04-04 10:41:05