class TorqueBoxLiteCommand
Public Instance Methods
create_deployment_descriptor(options, deploy_dir)
click to toggle source
# File bin/torquebox-lite, line 121 def create_deployment_descriptor(options, deploy_dir) opts = {:root => Dir.pwd, :dest_dir => deploy_dir} descriptor = TorqueBox::DeployUtils.basic_deployment_descriptor(opts) min_runtimes = options[:min_runtimes] max_runtimes = options[:max_runtimes] if min_runtimes != 1 && max_runtimes != 1 if max_runtimes < 1 $stderr.puts 'ERROR: max_runtimes must be greater than 0' exit 1 end if max_runtimes < min_runtimes $stderr.puts 'ERROR: max_runtimes must be greater than min_runtimes' exit 1 end descriptor['pooling'] = {} descriptor['pooling']['web'] = {} descriptor['pooling']['web']['lazy'] = false descriptor['pooling']['web']['min'] = min_runtimes descriptor['pooling']['web']['max'] = max_runtimes end deployed_name = TorqueBox::DeployUtils.deploy_yaml(descriptor, opts).first failed_file = File.join(deploy_dir, "#{deployed_name}.failed") if File.exists?(failed_file) FileUtils.rm(failed_file) end end
help()
click to toggle source
# File bin/torquebox-lite, line 56 def help self.class.task_help(shell, 'start') end
jruby_home()
click to toggle source
# File bin/torquebox-lite, line 88 def jruby_home File.expand_path(java.lang.System.getProperty('jruby.home')) end
run_server(options={})
click to toggle source
# File bin/torquebox-lite, line 92 def run_server(options={}) # If called from rake within a rails app, bundler will try # to init itself via RUBYOPT, which we don't want ENV.delete('RUBYOPT') base_dir = File.join(Dir.pwd, 'torquebox-lite') config_dir = File.join(TorqueBox::DeployUtils.jboss_home, 'standalone', 'configuration') deploy_dir = File.join(base_dir, 'deployments') FileUtils.mkdir_p(base_dir) FileUtils.mkdir_p(deploy_dir) create_deployment_descriptor(options, deploy_dir) options[:pass_through] ||= '' options[:pass_through] << " -Djboss.server.base.dir=#{base_dir}" options[:pass_through] << " -Djboss.server.config.dir=#{config_dir}" options[:jvm_options] ||= '' options[:jvm_options] << " -Dorg.torquebox.core.datasource.enabled=false" options[:jvm_options] << " -Dorg.torquebox.web.force_http_connector_start=true" options[:jvm_options] << " -Dtorquebox.http.port=#{options[:port]}" if options[:port] options[:jvm_options] << " #{strip_jvm_properties_from_jruby_opts}" Dir.chdir(TorqueBox::DeployUtils.jboss_home) do TorqueBox::DeployUtils.set_java_opts("#{options[:jvm_options]} #{TorqueBox::DeployUtils.jruby_opts_properties}") TorqueBox::DeployUtils.exec_command(TorqueBox::DeployUtils.run_command_line(options).join(' ')) end end
setup_environment()
click to toggle source
# File bin/torquebox-lite, line 61 def setup_environment ENV['TORQUEBOX_HOME'] = torquebox_home ENV['JBOSS_HOME'] = "#{ENV['TORQUEBOX_HOME']}/jboss" ENV['JRUBY_HOME'] = jruby_home ENV['JBOSS_OPTS'] = "-Djruby.home=#{jruby_home}" # Match load-path of booted application to load-path of this script ENV['RUBYLIB'] = "#{ENV['RUBYLIB']}:#{$:.join(':')}" end
start()
click to toggle source
# File bin/torquebox-lite, line 42 def start setup_environment run_server(:max_threads => options['max-threads'], :bind_address => options['bind-address'], :port => options['port'], :port_offset => options['port-offset'], :pass_through => options['extra'], :node_name => options['node-name'], :data_directory => options['data-directory'], :jvm_options => options['jvm-options'], :min_runtimes => options['min-runtimes'], :max_runtimes => options['max-runtimes']) end
strip_jvm_properties_from_jruby_opts()
click to toggle source
# File bin/torquebox-lite, line 149 def strip_jvm_properties_from_jruby_opts jruby_opts = ENV['JRUBY_OPTS'] return '' if jruby_opts.nil? jvm_properties = [] properties = jruby_opts.split(' ') properties.each do |property| if property =~ /^-J.+/ jvm_properties << property.sub(/-J/, '') ENV['JRUBY_OPTS'] = ENV['JRUBY_OPTS'].sub(property, '').strip end end jvm_properties.join(' ') end
torquebox_home()
click to toggle source
# File bin/torquebox-lite, line 70 def torquebox_home if ((Gem::Version.new(Gem::VERSION) <=> Gem::Version.new('1.8.9')) < 0) home = Gem.searcher.find('torquebox-lite') else home = Gem::Specification.find_by_name('torquebox-lite') end home.full_gem_path if home rescue Exception => e # User may be using Bundler in standalone mode or something else # funky so fall back to searching the load path $:.each do |path| if path =~ /^(.+torquebox-lite-.+?)\/lib$/ return $1 end end nil end