Ping Event for Rails & Mongoid
I use New Relic to keep my heroku dyno from falling into the 1-hour of inactivity. This little controller/action is what I use. It also checks if the MongoDB connection is still alive for an added bonus.
class PingController < ApplicationController
def ping
if Mongoid.default_session.command(ping: 1)
render :text => "pong"
else
render :status => 500
end
end
end
Written by Christopher Garvis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#