Почему cron терпит неудачу? - PullRequest
0 голосов
/ 03 апреля 2012

поэтому у меня есть эти два задания cron (но, как вы можете видеть на экранах, они терпят неудачу, но я не вижу никаких исключений в журналах.): Cron Fail

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 показывает это как Failed ?

Ответы [ 2 ]

0 голосов
/ 04 апреля 2012
  • Можете ли вы получить URL-адреса, которые вы добавляете в очередь задач (т.е. / tasks / PopularUpdate)?
  • Когда вы вводите URL-адрес задания cron вручную, он делает то, что предполагает?
  • Разве журналы в консоли администратора не показывают ошибок (по запросу cron)?
  • Почему у вас есть перенаправление в конце вашего обработчика заданий cron (AddTaskHandler)? Попробуйте удалить его.

.. Фредрик

0 голосов
/ 03 апреля 2012
  1. Вы должны поместить обработчик catch-all (/.*) в конец раздела обработчиков в app.yaml.
  2. Проверьте базовую / cron / addTask в браузере, работает ли она?
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...