Skip to content

Commit d45990b

Browse files
Add DOMAIN env var
1 parent 8b82c41 commit d45990b

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

config/puma.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
else
1111
system("node node-server/server-dev.js --ruby-port=#{rubyPort} --node-port=9293 &")
1212
end
13-
elsif ENV['SP'] == 'true'
14-
workers 1
13+
elsif ENV['WP'] != nil
14+
workers ENV['WP'].to_i
1515
before_fork do
16-
puts "Single Process Mode".colorize(:red)
16+
puts "The amount of proccesses is: #{ENV['WP']}".colorize(:green)
1717
puts "Master Process ID: #{Process.pid}".colorize(:green)
1818
puts "Starting Server...".colorize(:green)
1919
rubyPort = 9292

main.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
}
2727
#Validate the YML file
2828
validateYML()
29+
#Validate the ENV variables
30+
validateEnv()
2931
#Encrypted cookies
3032
use Rack::Session::EncryptedCookie, cookie_options
3133
#csrf
@@ -38,7 +40,7 @@
3840
if request.path_info == '/auth'
3941
return
4042
#any route on the main domain
41-
elsif request.url.include? Settings.mainURL
43+
elsif request.url.include? ENV['DOMAIN'] || Settings.mainURL
4244
return
4345
else
4446
auth()

require.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
require './ruby/utils.rb'
1414
require './ruby/uv.rb'
1515
require './ruby/auth.rb'
16-
require './ruby/yamlValidator.rb'
16+
require './ruby/validator.rb'

ruby/yamlValidator.rb renamed to ruby/validator.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ def validateYML
5252
exit
5353
end
5454
end
55+
56+
def validateEnv
57+
if ENV['DOMAIN'] != nil
58+
if ENV['DOMAIN'] !~ /\A#{URI::regexp(['http', 'https'])}\z/
59+
puts "Domain is not a valid URL".red
60+
exit
61+
elsif ENV['DOMAIN'] !~ /\/\z/
62+
puts "Domain must end with a /".red
63+
exit
64+
end
65+
end
66+
end

0 commit comments

Comments
 (0)