Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 42 lines (33 sloc) 0.887 kb
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
1 require 'sinatra'
2 require 'json'
a88ffa5 @tlozoot actually working with exceptions and latest ruby!
tlozoot authored
3 require 'redis'
4 require 'redis-lock'
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
5
cebae29 @tlozoot s/chunk/task
tlozoot authored
6 require './lib/tasks'
3299d3d @tlozoot major refactoring; import methods involving credits are now threadsaf…
tlozoot authored
7 require './lib/workers'
0826f95 @tlozoot exceptions!!! or, unleashing the awesomeness of ruby. (tests are stil…
tlozoot authored
8 require './lib/exceptions'
a88ffa5 @tlozoot actually working with exceptions and latest ruby!
tlozoot authored
9 require './lib/json_responder'
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
10
11 NUM_STARTING_CREDITS = 12
97423a8 @tlozoot default port should be 5 digits long
tlozoot authored
12 DEFAULT_PORT = 26262
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
13 DEFAULT_WORKER_TTL = 60
14 DEFAULT_CHUNK_TTL = 86400 # 1 day
3299d3d @tlozoot major refactoring; import methods involving credits are now threadsaf…
tlozoot authored
15 LOCK_TIMEOUT = 10
16 LOCK_MAX_ATTEMPTS = 100
0826f95 @tlozoot exceptions!!! or, unleashing the awesomeness of ruby. (tests are stil…
tlozoot authored
17 WORKERS_PER_CHUNK = 3
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
18
19 configure do
20 # Set up Redis
21 uri = URI.parse(ENV["REDISTOGO_URL"])
22 REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
a1f6c09 @tlozoot documentation rocks
tlozoot authored
23
a88ffa5 @tlozoot actually working with exceptions and latest ruby!
tlozoot authored
24 # Encode every response with JSON
25 use JSONResponder
0826f95 @tlozoot exceptions!!! or, unleashing the awesomeness of ruby. (tests are stil…
tlozoot authored
26
27 # Use custom exception handling
a88ffa5 @tlozoot actually working with exceptions and latest ruby!
tlozoot authored
28 set :raise_errors, false
0826f95 @tlozoot exceptions!!! or, unleashing the awesomeness of ruby. (tests are stil…
tlozoot authored
29 set :show_exceptions, false
e24f112 @tlozoot sinatra wants code not http_status for now
tlozoot authored
30 set :use_code, true # Will be necessary in Sinatra 1.4.x
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
31 end
32
33 configure :production, :development do
34 REDIS.select(0) # Use default database
35 end
36
37 configure :test do
94681cb @tlozoot we dont actually want to test on our production db though.'
tlozoot authored
38 REDIS.select(1) # Use a different test DB
8ad9948 @tlozoot Rake > custom dev stuff
tlozoot authored
39 REDIS.flushdb
40 end
0826f95 @tlozoot exceptions!!! or, unleashing the awesomeness of ruby. (tests are stil…
tlozoot authored
41
Something went wrong with that request. Please try again.