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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With