From 618241a458df9f17394252a03d99b6c9c7f18ce5 Mon Sep 17 00:00:00 2001
From: Mathias Meyer <meyer@paperplanes.de>
Date: Mon, 26 Aug 2013 15:30:07 +0200
Subject: [PATCH] Add an uptime endpoint for Pingdom.

Sends a simple database query to see if we can still connect
to the database. Should help us detect issues like yesterday's
EC2 issues earlier.
---
 lib/travis/api/app/endpoint/uptime.rb | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 lib/travis/api/app/endpoint/uptime.rb

diff --git a/lib/travis/api/app/endpoint/uptime.rb b/lib/travis/api/app/endpoint/uptime.rb
new file mode 100644
index 00000000..9b8b618f
--- /dev/null
+++ b/lib/travis/api/app/endpoint/uptime.rb
@@ -0,0 +1,16 @@
+require 'travis/api/app'
+
+class Travis::Api::App
+  class Endpoint
+    class Uptime < Endpoint
+      get '/' do
+        begin
+          ActiveRecord::Base.connection.execute('select 1')
+          [200, "OK"]
+        rescue => e
+          [500, "Error: #{e.message}"]
+        end
+      end
+    end
+  end
+end