I have followed this guide to create cron job for my Rails app, but the HTTP status code is always returns 301 and my job status is failed. Am I missing something?
controller:
class CronsController < ApplicationController
def example
if request.headers["X-Appengine-Cron"]
Example.do_something
head :ok
else
head :not_found
end
end
end
routes:
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
result from gcloud app logs read
2017-08-26 07:00:05 default[20170823t153316] "GET /crons/example" 301
Two possibilities, both issues because app engine cron does not follow redirects:
url: /crons/example/
) and that fixed it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.