forked from onetimesecret/onetimesecret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
49 lines (43 loc) · 1.32 KB
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Onetime Rackup
#
# Usage:
#
# $ thin -e dev -R config.ru -p 7143 start
# $ tail -f /var/log/system.log
ENV['RACK_ENV'] ||= 'prod'
ENV['APP_ROOT'] = ::File.expand_path(::File.join(::File.dirname(__FILE__)))
$:.unshift(::File.join(ENV['APP_ROOT']))
$:.unshift(::File.join(ENV['APP_ROOT'], 'lib'))
$:.unshift(::File.join(ENV['APP_ROOT'], 'app'))
require 'otto'
require 'onetime/app/web'
require 'onetime/app/api'
require 'onetime/app/colonel'
PUBLIC_DIR = "#{ENV['APP_ROOT']}/public/web"
APP_DIR = "#{ENV['APP_ROOT']}/lib/onetime/app"
apps = {
'/' => Otto.new("#{APP_DIR}/web/routes"),
'/api' => Otto.new("#{APP_DIR}/api/routes"),
'/colonel' => Otto.new("#{APP_DIR}/colonel/routes")
}
Onetime.load! :app
if Otto.env?(:dev)
# DEV: Run web apps with extra logging and reloading
apps.each_pair do |path,app|
map(path) {
use Rack::CommonLogger
use Rack::Reloader, 1
app.option[:public] = PUBLIC_DIR
app.add_static_path '/favicon.ico'
# TODO: Otto should check for not_found method instead of settign it here.
#otto.not_found = [404, {'Content-Type'=>'text/plain'}, ["Server error2"]]
run app
}
end
else
# PROD: run barebones webapps
apps.each_pair do |path,app|
map(path) { run app }
end
#$SAFE = 1 # http://www.rubycentral.com/pickaxe/taint.html
end