forked from mu-semtech/mu-ruby-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.rb
38 lines (32 loc) · 857 Bytes
/
web.rb
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
require 'sinatra'
require 'logger'
require 'sparql/client'
require 'json'
require 'rdf/vocab'
require 'bson'
require_relative 'sinatra_template/helpers.rb'
configure do
set :graph, ENV['MU_APPLICATION_GRAPH']
set :sparql_client, SPARQL::Client.new(ENV['MU_SPARQL_ENDPOINT'])
###
# Logging
###
log_dir = '/logs'
Dir.mkdir(log_dir) unless Dir.exist?(log_dir)
# Keep 10 log files of 100 MB in size
log = Logger.new("#{log_dir}/#{settings.environment}.log", 10, 100*1024*1024)
log.level = Kernel.const_get("Logger::#{ENV['LOG_LEVEL'].upcase}")
set :log, log
end
###
# Vocabularies
###
include RDF
MU = RDF::Vocabulary.new('http://mu.semte.ch/vocabularies/')
MU_CORE = RDF::Vocabulary.new(MU.to_uri.to_s + 'core/')
###
# Helpers
###
helpers SinatraTemplate::Helpers
app_file = ENV['APP_ENTRYPOINT']
require_relative "ext/#{app_file}"