Created
July 17, 2009 12:24
-
-
Save hvirring/149028 to your computer and use it in GitHub Desktop.
Monitoring Rails POST requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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