-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ru
73 lines (51 loc) · 1.84 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
71
72
73
# This config file loads the Rails and Sinatra apps and then cascades them.
# The Rails app includes the Grape API.
require 'rubygems'
require 'bundler'
require 'dotenv'
##########################
# ENV VARIABLES #
##########################
Dotenv.load
# We need to set this here so it is not overridden inside server/config/boot.rb
ENV['BUNDLE_GEMFILE'] ||= 'Gemfile'
# Default to the dev environment
ENV['RACK_ENV'] ||= 'development'
ENV['CASCADED'] = 'true'
##########################
# BUNDLER #
##########################
# Load the default gemset, as well as those particular to the current environment
Bundler.require(:default, ENV['RACK_ENV'].to_sym)
##########################
# APP LOADING #
##########################
require_relative 'server/config/environment'
require_relative 'client/app'
##########################
# CASCADE #
##########################
# Rack::Cascade sends all routes to the first Rack app, and if it responds with a 404
# Rack passes the request on to the next Rack app.
cascaded_app = Rack::Cascade.new [WFDinnerApp, WFDinnerServer::Application]
##########################
# Sidekiq Interface #
##########################
# In non-development environments, we protect the Sidekiq interface with basic auth
require 'sidekiq/web'
if ENV['RACK_ENV'] == 'development'
sidekiq = Sidekiq::Web
else
sidekiq = Rack::Auth::Basic.new(Sidekiq::Web.new) do |username, password|
username == ENV['SIDEKIQ_USER']
password == ENV['SIDEKIQ_PW']
end
end
##########################
# STARTUP #
##########################
# Rack::Cascade sends all routes to the first Rack app, and if it responds with a 404
# Rack passes the request on to the next Rack app.
#
# /sidekiq routes to the sidekiq app
run Rack::URLMap.new('/' => cascaded_app, '/sidekiq' => sidekiq)