-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.ru
executable file
·70 lines (52 loc) · 1.55 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# encoding: UTF-8
# #!/usr/bin/env rackup
# #\ -w -p 4568
$:.unshift(File.expand_path('../lib', __FILE__))
require 'rubygems' || Gem.clear_paths
require 'bundler'
Bundler.setup
require 'sinatra'
require 'dalli'
require 'rack/cache'
require 'logger'
# Rackup stuff:
require File.expand_path '../lib/application.rb', __FILE__
# Global config
set :logging, true
set :raise_errors, true
set :show_exceptions, true
set :static, true
set :root, File.dirname(__FILE__)
set :environment, (ENV['RACK_ENV'] || 'production').to_sym
# LOGGING
if settings.environment == :production
puts "Mode set to #{settings.environment.inspect}, logging to sinatra.log"
$logger = Logger.new('sinatra.log', 10, 3600*24*7)
else
puts "Mode set to #{settings.environment.inspect}, logging to console"
$logger = Logger.new(STDOUT)
$logger.formatter = lambda {|severity, datetime, progname, msg| "#{msg}\n"}
end
# CACHING
# Defined in ENV on Heroku. To try locally, start memcached and uncomment next line:
#ENV["MEMCACHE_SERVERS"] = "localhost"
if memcache_servers = ENV["MEMCACHE_SERVERS"]
use Rack::Cache,
:verbose=> true,
:metastore=> "memcached://#{memcache_servers}",
:entitystore=> "memcached://#{memcache_servers}"
else
# File Cachestore
use Rack::Cache,
:verbose => true,
:metastore => "file:" + File.expand_path("../cache/meta", __FILE__),
:entitystore => "file:" + File.expand_path("../cache/body", __FILE__)
end
disable :run, :reload
#require 'rack/protection'
#use Rack::Protection
# Bootstrap
# classic:
# run Sinatra::Application
# modular:
run Kosa