lib/ruby_wolf/cli.rb in ruby_wolf-0.3.0 vs lib/ruby_wolf/cli.rb in ruby_wolf-0.3.1
- old
+ new
@@ -10,10 +10,12 @@
@app_root = `pwd`.to_s.strip
end
def run
parse_options
+ set_environment
+
raise 'Rack file not found' unless File.exist?(rack_file)
@server = RubyWolf::Server.new(rack_file, configs)
@server.start
end
@@ -36,10 +38,14 @@
opts.on('-w WORKER', '--worker=WORKER', 'Number of worker processes') do |arg|
@configs[:worker] = arg.to_i
end
+ opts.on('-e ENVIRONMENT', '--environment=ENVIRONMENT', 'Current environment') do |arg|
+ @configs[:environment] = arg
+ end
+
opts.on('-h', '--help', 'Show the usages') do
puts opts
exit
end
end
@@ -49,8 +55,13 @@
private
def rack_file
"#{@app_root}/config.ru"
+ end
+
+ def set_environment
+ ENV['RAILS_ENV'] = configs[:environment]
+ ENV['RACK_ENV'] = configs[:environment]
end
end
end