我已按照this guide为我的Rails应用创建了cron作业,但HTTP状态代码始终返回301并且我的作业状态失败。我错过了什么吗?
控制器:
class CronsController < ApplicationController
def example
if request.headers["X-Appengine-Cron"]
Example.do_something
head :ok
else
head :not_found
end
end
end
路线:
get 'crons/example', to: 'crons#example'
cron.yaml
cron:
- description: my cron example
url: /crons/example
schedule: every 2 hours from 03:00 to 07:00
来自gcloud app logs read
2017-08-26 07:00:05 default[20170823t153316] "GET /crons/example" 301
答案 0 :(得分:5)
两种可能性,这两个问题都是因为app引擎cron不遵循重定向:
url: /crons/example/
)并修复了它。