refactored environment settings
This commit is contained in:
parent
652439dc11
commit
ac95f71e43
|
@ -1,42 +1,6 @@
|
|||
# this is the entry point for these two contexts:
|
||||
# - running red_storm.rake
|
||||
# - at remote cluster topology execution. Once topology_launcher.rb has submitted the topology
|
||||
# the spouts and bolts classes will be instanciated and will require red_storm.rb
|
||||
|
||||
# we depends on rubygems begings loaded at this point for setting up gem/bundle environments
|
||||
# explicitely requiring rubygems is required in remote cluster environment
|
||||
require 'rubygems'
|
||||
|
||||
# setup some environment constants
|
||||
# this is required here and in topology_launcher.rb which are both
|
||||
# entry points in redstorm.
|
||||
module RedStorm
|
||||
TOPOLOGY_LAUNCHED = defined?(LAUNCH_PATH)
|
||||
|
||||
# do not redefine if already defined in topology_launcher.rb
|
||||
unless TOPOLOGY_LAUNCHED
|
||||
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
||||
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
||||
|
||||
if JAR_CONTEXT
|
||||
BASE_PATH = LAUNCH_PATH
|
||||
else
|
||||
BASE_PATH = Dir.pwd
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless RedStorm::JAR_CONTEXT
|
||||
# in JAR context red_storm.rb and red_storm/* is in the JAR root.
|
||||
# otherwise this is in lib/...
|
||||
$:.unshift "#{RedStorm::BASE_PATH}/lib"
|
||||
end
|
||||
|
||||
unless RedStorm::TOPOLOGY_LAUNCHED
|
||||
require 'red_storm/environment'
|
||||
RedStorm.setup_gems if RedStorm::JAR_CONTEXT
|
||||
end
|
||||
|
||||
require 'red_storm/environment'
|
||||
require 'red_storm/version'
|
||||
require 'red_storm/configuration'
|
||||
require 'red_storm/application'
|
||||
|
|
|
@ -1,28 +1,25 @@
|
|||
module RedStorm
|
||||
# LAUNCH_PATH, BASE_PATH and JAR_CONTEXT must be set before requiring this module
|
||||
# typically, they must be set in either red_storm.rb and topology_launcher.rd
|
||||
# which are the 2 entry points
|
||||
|
||||
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
||||
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!\/red_storm$/)
|
||||
|
||||
if JAR_CONTEXT
|
||||
REDSTORM_HOME = LAUNCH_PATH
|
||||
TARGET_PATH = LAUNCH_PATH
|
||||
BUNDLE_GEMFILE = "#{TARGET_PATH}/bundler/Gemfile"
|
||||
BUNDLE_PATH = "#{TARGET_PATH}/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
||||
BASE_PATH = File.expand_path(LAUNCH_PATH + '/..')
|
||||
REDSTORM_HOME = BASE_PATH
|
||||
TARGET_PATH = BASE_PATH
|
||||
|
||||
GEM_PATH = "#{TARGET_PATH}/gems/"
|
||||
ENV["GEM_PATH"] = GEM_PATH
|
||||
else
|
||||
REDSTORM_HOME = File.expand_path(LAUNCH_PATH + '/..')
|
||||
BASE_PATH = Dir.pwd
|
||||
REDSTORM_HOME = File.expand_path(LAUNCH_PATH + '/../..')
|
||||
TARGET_PATH = "#{BASE_PATH}/target"
|
||||
BUNDLE_GEMFILE = "#{TARGET_PATH}/gems/bundler/Gemfile"
|
||||
BUNDLE_PATH = "#{TARGET_PATH}/gems/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
||||
GEM_PATH = "#{TARGET_PATH}/gems/gems"
|
||||
end
|
||||
|
||||
def setup_gems
|
||||
ENV['BUNDLE_GEMFILE'] = RedStorm::BUNDLE_GEMFILE
|
||||
ENV['BUNDLE_PATH'] = RedStorm::BUNDLE_PATH
|
||||
ENV["GEM_PATH"] = RedStorm::GEM_PATH
|
||||
ENV['BUNDLE_DISABLE_SHARED_GEMS'] = "1"
|
||||
end
|
||||
|
||||
module_function :setup_gems
|
||||
# puts("*** LAUNCH_PATH=#{LAUNCH_PATH}")
|
||||
# puts("*** JAR_CONTEXT=#{JAR_CONTEXT}")
|
||||
# puts("*** BASE_PATH=#{BASE_PATH}")
|
||||
# puts("*** REDSTORM_HOME=#{REDSTORM_HOME}")
|
||||
# puts("*** TARGET_PATH=#{TARGET_PATH}")
|
||||
# puts("*** GEM_PATH=#{GEM_PATH}") if defined?(GEM_PATH)
|
||||
end
|
||||
|
|
|
@ -17,22 +17,6 @@ java_import 'redstorm.storm.jruby.JRubySpout'
|
|||
|
||||
java_package 'redstorm'
|
||||
|
||||
# setup some environment constants
|
||||
# this is required here and in red_storm.rb which are both
|
||||
# entry points in redstorm.
|
||||
module RedStorm
|
||||
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
||||
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
||||
|
||||
if JAR_CONTEXT
|
||||
BASE_PATH = LAUNCH_PATH
|
||||
LIB_PATH = "#{BASE_PATH}/lib"
|
||||
else
|
||||
BASE_PATH = Dir.pwd
|
||||
LIB_PATH = "#{BASE_PATH}/target/lib"
|
||||
end
|
||||
end
|
||||
|
||||
# TopologyLauncher is the application entry point when launching a topology. Basically it will
|
||||
# call require on the specified Ruby topology class file path and call its start method
|
||||
class TopologyLauncher
|
||||
|
@ -52,11 +36,9 @@ class TopologyLauncher
|
|||
env = args[0].to_sym
|
||||
class_path = args[1]
|
||||
|
||||
$:.unshift "#{RedStorm::BASE_PATH}"
|
||||
$:.unshift "#{RedStorm::LIB_PATH}"
|
||||
|
||||
require 'red_storm/environment'
|
||||
RedStorm.setup_gems
|
||||
launch_path = File.expand_path(File.dirname(__FILE__))
|
||||
$:.unshift File.expand_path(launch_path + '/..') # lib path for redstorm dir
|
||||
$:.unshift File.expand_path(launch_path + '/../..') # root path for topologies dir
|
||||
|
||||
require "#{class_path}"
|
||||
|
||||
|
|
Loading…
Reference in New Issue