desc "This task is called by the Heroku cron add-on" task :call_page => :environmentdo require'net/http' uri = URI.parse('http://test-app.herokuapp.com/') Net::HTTP.get(uri) end
(3) taskの動作確認
以下を実行して動作を確認。
Heroku run Rake call_page
heroku logsで動作確認。エラーメッセージが出ていなければ成功。
heroku logs -t
2012-11-26T03:18:17+00:00 heroku[api]: Starting process with command `bundle exec rake call_page` by email@example.com 2012-11-26T03:18:21+00:00 heroku[run.1]: Awaiting client 2012-11-26T03:18:21+00:00 heroku[run.1]: Starting process with command `bundle exec rake call_page` 2012-11-26T03:18:27+00:00 app[web.1]: Started GET "/"for xx.xx.xx.xx at 2012-11-26 12:18:27 +0900 2012-11-26T03:18:27+00:00 app[web.1]: Processing by ArticlesController#index as */* 2012-11-26T03:18:27+00:00 app[web.1]: Rendered /index.html.haml within layouts/application (3.5ms) 2012-11-26T03:18:27+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 7.9ms | ActiveRecord: 0.0ms) 2012-11-26T03:18:27+00:00 heroku[router]: at=info method=GET path=/ host=test-app.herokuapp.com fwd= dyno=web.1 queue=0 wait=0ms connect=4ms service=21ms status=200 bytes=704 2012-11-26T03:18:27+00:00 heroku[run.1]: Client connection closed. Sending SIGHUP to all processes 2012-11-26T03:18:28+00:00 heroku[run.1]: Process exited with status 0 2012-11-26T03:18:28+00:00 heroku[run.1]: State changed from up to complete 2012-11-26T03:18:21+00:00 heroku[run.1]: State changed from starting to up