Permalink
Browse files

Logging, adding redis by default, pulse action

  • Loading branch information...
1 parent 2fac235 commit 4cadcd0eaad72586317b3ac818559eaa853d039a @winton committed May 26, 2011
View
@@ -6,4 +6,5 @@ gem_template:
lilypad: =0.3.1
rack-flash: =0.1.1
rack-test: =0.6.0
+ redis: =2.1.1
sinatra: =1.2.6
View
@@ -5,11 +5,13 @@
$:.unshift File.dirname(__FILE__)
require 'gem_template/boot/application'
+require 'gem_template/boot/log'
require 'gem_template/boot/sinatra'
require 'gem_template/boot/session'
require 'gem_template/boot/flash'
require 'gem_template/boot/haml'
require 'gem_template/boot/lilypad'
+require 'gem_template/boot/redis'
require 'gem_template/boot/controller'
require 'gem_template/boot/helper'
require 'gem_template/boot/model'
@@ -0,0 +1,6 @@
+Application.class_eval do
+
+ log = File.new("#{root}/log/#{environment}.log", "a")
+ STDOUT.reopen(log)
+ STDERR.reopen(log)
+end
@@ -0,0 +1,26 @@
+require 'uri'
+require 'redis'
+
+Application.class_eval do
+ helpers do
+
+ def redis
+ define_redis
+ end
+ end
+end
+
+def define_redis
+ $redis ||= (
+ url = URI('redis://localhost:6379/0')
+
+ ::Redis.new(
+ :host => url.host,
+ :port => url.port,
+ :db => url.path[1..-1],
+ :password => url.password
+ )
+ )
+end
+
+define_redis
@@ -1,6 +0,0 @@
-Application.class_eval do
-
- get '/' do
- "#{self.class.environment}"
- end
-end
@@ -0,0 +1,6 @@
+Application.class_eval do
+
+ get '/pulse' do
+ "#{self.class.environment} OK"
+ end
+end

0 comments on commit 4cadcd0

Please sign in to comment.