Skip to content

Instantly share code, notes, and snippets.

@hvirring
Created July 17, 2009 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvirring/149028 to your computer and use it in GitHub Desktop.
Save hvirring/149028 to your computer and use it in GitHub Desktop.
Monitoring Rails POST requests
class HomeController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => :post_up
def index
end
# monitored by http://uptime.alal.com/uptime/
# this will test if Rails is up and responding to GETs and POSTs
def rails_up
url = URI.parse(url_for(:action => 'post_up'))
res = Net::HTTP.post_form(url, {})
# body will be "success" if POST request is successful
render :text => res.body
rescue Exception => e
render :text => "error: #{e.to_s}"
end
# verify that POST requests are working
# we've had problems with Apache segfaulting on POSTs
def post_up
render :text => request.post? ? "success" : "only POST allowed"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment