summaryrefslogtreecommitdiff
path: root/lib/environment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/environment.rb')
-rw-r--r--lib/environment.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/environment.rb b/lib/environment.rb
index c65e968..3a9319d 100644
--- a/lib/environment.rb
+++ b/lib/environment.rb
@@ -1,7 +1,7 @@
-# load configuration
-
+# set default environment
ENV['RACK_ENV'] = 'test' unless ENV['RACK_ENV']
+# load configuration
basedir = File.join(ENV['HOME'], ".opentox")
config_dir = File.join(basedir, "config")
@@tmp_dir = File.join(basedir, "tmp")
@@ -16,3 +16,18 @@ else
puts "Please edit #{config_file} and restart your application."
exit
end
+
+# configure redis database
+begin
+ case ENV['RACK_ENV']
+ when 'production'
+ @@redis = Redis.new :db => 0
+ when 'development'
+ @@redis = Redis.new :db => 1
+ when 'test'
+ @@redis = Redis.new :db => 2
+ @@redis.flush_db
+ end
+rescue
+ puts "Redis database not running, please start it with 'rake redis:start'."
+end