Module: TorqueBox::DeployUtils Private
- Defined in:
- lib/torquebox/deploy_utils.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .archive_name(root = Dir.pwd) ⇒ Object private
- .basic_deployment_descriptor(options = {}) ⇒ Object private
- .check_opt_torquebox ⇒ Object private
- .check_server ⇒ Object private
- .cluster_config_file ⇒ Object private
- .config_dir ⇒ Object private
-
.create_archive(opts = {}) ⇒ Object
private
name: (string) what to call the resulting knob file app_dir: (string) where the application to be packaged is dest_dir: (string) where to put the resulting knob file exclude: (string) string or regex of files to exclude from the archive precompile_assets: (boolean) whether or not to precompile assets.
- .create_knob_archive(app_dir, archive_path, excludes) ⇒ Object private
-
.create_symlink ⇒ Object
private
TODO: This is not windows friendly.
- .deploy_archive(opts = {}) ⇒ Object private
- .deploy_dir ⇒ Object private
- .deploy_yaml(deployment_descriptor, opts = {}) ⇒ Object private
- .deployed_file(name, deploy_dir = DeployUtils.deploy_dir) ⇒ Object private
- .deployers_dir ⇒ Object private
- .deployment_descriptors ⇒ Object private
- .deployment_name(root = Dir.pwd) ⇒ Object private
- .deployment_status ⇒ Object private
- .dodeploy_file(name, deploy_dir = DeployUtils.deploy_dir) ⇒ Object private
- .eap? ⇒ Boolean private
-
.exec_command(cmd) ⇒ Object
private
Used when we want to effectively replace this process with the given command.
-
.fake_exec(cmd) ⇒ Object
private
Used to run a command as a subprocess.
- .find_option(opt, key) ⇒ Object private
- .freeze_gems(app_dir = Dir.pwd) ⇒ Object private
- .is_deployed?(appname = deployment_name) ⇒ Boolean private
- .jboss_conf ⇒ Object private
- .jboss_home ⇒ Object private
- .jruby_command(cmd) ⇒ Object private
- .jruby_opts_properties ⇒ Object private
- .modules_dir ⇒ Object private
- .normalize_archive_name(name) ⇒ Object private
- .normalize_yaml_name(name) ⇒ Object private
-
.opt_dir ⇒ Object
private
Used by upstart and launchd.
- .opt_torquebox ⇒ Object private
- .package_gems(app_dir, package_without) ⇒ Object private
- .precompile_assets(app_dir) ⇒ Object private
- .properties_dir ⇒ Object private
- .readpartial(stream) ⇒ Object private
- .rubylib_with_bundler(load_path) ⇒ Object private
- .run_command(cmd) ⇒ Object private
- .run_command_line(opts = {}) ⇒ Object private
- .run_server(options = {}) ⇒ Object private
- .server_dir ⇒ Object private
- .set_java_opts(options) ⇒ Object private
- .standalone_config_file ⇒ Object private
- .strip_jvm_properties_from_jruby_opts ⇒ Object private
-
.sys_root ⇒ Object
private
TODO: This is not windows friendly, is it?.
- .torquebox_home ⇒ Object private
- .torquebox_modules_dir ⇒ Object private
- .undeploy_archive(opts = {}) ⇒ Object private
- .undeploy_yaml(opts = {}) ⇒ Object private
- .windows? ⇒ Boolean private
Class Method Details
.archive_name(root = Dir.pwd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'lib/torquebox/deploy_utils.rb', line 107 def archive_name(root = Dir.pwd) normalize_archive_name( File.basename( root || Dir.pwd ) ) end |
.basic_deployment_descriptor(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/torquebox/deploy_utils.rb', line 291 def basic_deployment_descriptor( = {}) env = [:env] || ['env'] env ||= defined?(RACK_ENV) ? RACK_ENV : ENV['RACK_ENV'] env ||= defined?(::Rails) && Rails.respond_to?(:env) ? ::Rails.env : ENV['RAILS_ENV'] root = [:root] || ['root'] || Dir.pwd context_path = [:context_path] || ['context_path'] d = {} d['application'] = {} d['application']['root'] = root d['environment'] = {} d['environment']['RACK_ENV'] = env.to_s if env if context_path d['web'] = {} d['web']['context'] = context_path end d end |
.check_opt_torquebox ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
120 121 122 123 |
# File 'lib/torquebox/deploy_utils.rb', line 120 def check_opt_torquebox raise "TorqueBox not installed in #{opt_torquebox}" unless ( File.exist?( opt_torquebox ) ) puts "TorqueBox install OK: #{opt_torquebox}" end |
.check_server ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
115 116 117 118 |
# File 'lib/torquebox/deploy_utils.rb', line 115 def check_server raise "#{jboss_home} doesn't appear to be a valid TorqueBox install" unless File.exist?( torquebox_modules_dir ) puts "TorqueBox installation appears OK" end |
.cluster_config_file ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 |
# File 'lib/torquebox/deploy_utils.rb', line 78 def cluster_config_file eap? ? "torquebox-full-ha.xml" : "standalone-ha.xml" end |
.config_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# File 'lib/torquebox/deploy_utils.rb', line 70 def config_dir File.join("#{server_dir}","configuration") end |
.create_archive(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
name: (string) what to call the resulting knob file app_dir: (string) where the application to be packaged is dest_dir: (string) where to put the resulting knob file exclude: (string) string or regex of files to exclude from the archive precompile_assets: (boolean) whether or not to precompile assets. this is rails-specific. package_gems: (boolean) whether or not to install all bundle gems to vendor/bundle (this
is rather convenient as it means that you don't have to run bundle
install on your production servers)
package_without: (array) all the bundler groups to run bundle install without (cuts down
on package size by snipping out potentially inappropriate
dependencies for a production environment).
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/torquebox/deploy_utils.rb', line 194 def create_archive(opts = {}) archive = normalize_archive_name( find_option( opts, 'name' ) || archive_name ) app_dir = find_option( opts, 'app_dir' ) || Dir.pwd dest_dir = find_option( opts, 'dest_dir' ) || Dir.pwd excludes = find_option( opts, 'exclude' ) || "" should_precompile_assets = find_option( opts, 'precompile_assets' ) == true should_package_gems = find_option( opts, 'package_gems' ) == true package_without = find_option( opts, 'package_without' ) || Array.new if should_precompile_assets precompile_assets( app_dir ) raise 'Error precompiling assets' unless $? == 0 end archive_path = File.join( dest_dir, archive ) archive_proc = lambda { create_knob_archive( app_dir, archive_path, excludes ) } if should_package_gems package_gems( app_dir, package_without ) { raise 'Error packaging gems' unless $? == 0 archive_proc.call } else archive_proc.call end archive_path end |
.create_knob_archive(app_dir, archive_path, excludes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/torquebox/deploy_utils.rb', line 260 def create_knob_archive(app_dir, archive_path, excludes) default_skip_files = %w{ ^log/ ^tmp/ ^test/ ^spec/ ^[^/]*\.knob$ vendor/.*cache/.*\.gem$ } opts_skip_files = excludes.split( /,/ ).map { |r| "^[^/]*#{r}" } skip_files = default_skip_files + opts_skip_files Dir.chdir( app_dir ) do include_files = [] Dir[ "**/**", ".bundle/**/**" ].each do |entry| unless File.directory?( entry ) || skip_files.any? { |regex| entry.match( regex ) } include_files << '"' + entry.to_s + '"' end end includes = Tempfile.new( "include-files" ) includes.write( include_files.join( "\n" ) ) includes.flush cmd = "jar cvf \"#{archive_path}\" @#{includes.path}" run_command( cmd ) includes.close( true ) end end |
.create_symlink ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: This is not windows friendly
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/torquebox/deploy_utils.rb', line 351 def create_symlink unless File.exist? opt_dir success = true if !File.writable?( sys_root ) puts "Cannot write to #{sys_root}. Please ensure #{opt_torquebox} points to your torquebox installation." success = false else puts "Creating #{opt_dir}" Dir.new( opt_dir ) end end unless File.exist?( opt_torquebox ) if File.writable?( opt_dir ) puts "Linking #{opt_torquebox} to #{torquebox_home}" File.symlink( torquebox_home, opt_torquebox ) else puts "Cannot link #{opt_torquebox} to #{torquebox_home}" success = false end end success end |
.deploy_archive(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
324 325 326 327 328 329 330 331 332 |
# File 'lib/torquebox/deploy_utils.rb', line 324 def deploy_archive(opts = {}) name = normalize_archive_name( find_option( opts, 'name' ) || archive_name ) archive_path = find_option( opts, 'archive_path' ) || File.join( Dir.pwd, name ) dest_dir = find_option( opts, 'dest_dir' ) || deploy_dir FileUtils.cp( archive_path, dest_dir ) archive = File.basename( archive_path ) FileUtils.touch( dodeploy_file( archive, dest_dir ) ) [archive, dest_dir] end |
.deploy_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 |
# File 'lib/torquebox/deploy_utils.rb', line 91 def deploy_dir File.join( "#{server_dir}", "deployments" ) end |
.deploy_yaml(deployment_descriptor, opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
313 314 315 316 317 318 319 320 321 322 |
# File 'lib/torquebox/deploy_utils.rb', line 313 def deploy_yaml(deployment_descriptor, opts = {}) name = normalize_yaml_name( find_option( opts, 'name' ) || deployment_name(opts[:root] || opts['root']) ) dest_dir = opts[:dest_dir] || opts['dest_dir'] || deploy_dir deployment = File.join( dest_dir, name ) File.open( deployment, 'w' ) do |file| YAML.dump( deployment_descriptor, file ) end FileUtils.touch( dodeploy_file( name, dest_dir ) ) [name, dest_dir] end |
.deployed_file(name, deploy_dir = DeployUtils.deploy_dir) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
338 339 340 |
# File 'lib/torquebox/deploy_utils.rb', line 338 def deployed_file(name, deploy_dir = DeployUtils.deploy_dir) File.join( deploy_dir, "#{name}" ) + ".deployed" end |
.deployers_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 |
# File 'lib/torquebox/deploy_utils.rb', line 95 def deployers_dir raise "Deployers directory no longer relevant" end |
.deployment_descriptors ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
475 476 477 |
# File 'lib/torquebox/deploy_utils.rb', line 475 def deployment_descriptors Dir.glob( "#{deploy_dir}/*-knob.yml" ).collect { |d| File.basename( d ) } end |
.deployment_name(root = Dir.pwd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 |
# File 'lib/torquebox/deploy_utils.rb', line 111 def deployment_name(root = Dir.pwd) normalize_yaml_name( File.basename( root || Dir.pwd ) ) end |
.deployment_status ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/torquebox/deploy_utils.rb', line 479 def deployment_status applications = {} deployment_descriptors.each do | descriptor | descriptor_path = File.join( deploy_dir, descriptor ) appname = descriptor.sub( /\-knob.yml/, '' ) applications[appname] = {} applications[appname][:descriptor] = descriptor_path applications[appname][:status] = case when File.exists?("#{descriptor_path}.dodeploy") "awaiting deployment" when File.exists?("#{descriptor_path}.deployed") "deployed" when File.exists?("#{descriptor_path}.failed") "deployment failed" else "unknown: try running `torquebox deploy #{appname}`" end end applications end |
.dodeploy_file(name, deploy_dir = DeployUtils.deploy_dir) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
334 335 336 |
# File 'lib/torquebox/deploy_utils.rb', line 334 def dodeploy_file(name, deploy_dir = DeployUtils.deploy_dir) File.join( deploy_dir, "#{name}" ) + ".dodeploy" end |
.eap? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 |
# File 'lib/torquebox/deploy_utils.rb', line 82 def eap? index_html = File.join( jboss_home, 'welcome-content', 'index.html' ) File.exists?( index_html ) && File.read( index_html ) =~ /EAP 6/ end |
.exec_command(cmd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used when we want to effectively replace this process with the given command. On Windows this does call Kernel#exec but on everything else we just delegate to fake_exec.
This is mainly so CTRL+C, STDIN, STDOUT, and STDERR work as expected across all operating systems.
401 402 403 404 |
# File 'lib/torquebox/deploy_utils.rb', line 401 def exec_command(cmd) exec(cmd) # windows? ? exec(cmd) : fake_exec(cmd) end |
.fake_exec(cmd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used to run a command as a subprocess
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/torquebox/deploy_utils.rb', line 407 def fake_exec(cmd) exiting = false IO.popen4(cmd) do |pid, stdin, stdout, stderr| stdout.sync = true stderr.sync = true trap("INT") do exiting = true stdin.close puts "caught SIGINT, shutting down" `taskkill /F /T /PID #{pid}` if windows? end # Don't join on stdin since interrupting a blocking read on # JRuby is pretty tricky Thread.new(stdin) { |stdin_io| begin until exiting stdin_io.write(readpartial(STDIN)) stdin_io.flush end rescue Errno::EBADF, IOError end } # Join on stdout/stderr since they'll be closed # automatically once TorqueBox exits [ Thread.new(stdout) { |stdout_io| begin while true STDOUT.write(readpartial(stdout_io)) end rescue EOFError end }, Thread.new(stderr) { |stderr_io| begin while true STDERR.write(readpartial(stderr_io)) end rescue EOFError end } ].each( &:join) end end |
.find_option(opt, key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
463 464 465 |
# File 'lib/torquebox/deploy_utils.rb', line 463 def find_option(opt, key) opt[key.to_sym] || opt[key] || ENV[key] || ENV[key.upcase] end |
.freeze_gems(app_dir = Dir.pwd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
284 285 286 287 288 289 |
# File 'lib/torquebox/deploy_utils.rb', line 284 def freeze_gems(app_dir = Dir.pwd) Dir.chdir( app_dir ) do jruby_command( '-S bundle package --all' ) jruby_command( '-S bundle install --local --deployment' ) end end |
.is_deployed?(appname = deployment_name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
151 152 153 |
# File 'lib/torquebox/deploy_utils.rb', line 151 def is_deployed?( appname = deployment_name ) File.exists?( File.join(deploy_dir, appname) ) end |
.jboss_conf ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/torquebox/deploy_utils.rb', line 48 def jboss_conf ENV['TORQUEBOX_CONF'] || ENV['JBOSS_CONF'] || 'standalone' end |
.jboss_home ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 |
# File 'lib/torquebox/deploy_utils.rb', line 31 def jboss_home jboss_home = File.(ENV['JBOSS_HOME']) if ENV['JBOSS_HOME'] jboss_home ||= File.join(File.(ENV['TORQUEBOX_HOME']), "jboss") if ENV['TORQUEBOX_HOME'] raise "$JBOSS_HOME is not set" unless jboss_home return jboss_home end |
.jruby_command(cmd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
375 376 377 378 379 380 381 382 383 |
# File 'lib/torquebox/deploy_utils.rb', line 375 def jruby_command(cmd) jruby = File.join( RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] ) jruby << case RUBY_VERSION when /^1\.8\./ then ' --1.8' when /^1\.9\./ then ' --1.9' when /^2\.0\./ then ' --2.0' end run_command( "#{jruby} #{cmd}" ) end |
.jruby_opts_properties ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
499 500 501 502 503 504 505 |
# File 'lib/torquebox/deploy_utils.rb', line 499 def jruby_opts_properties jruby_opts = ENV['JRUBY_OPTS'] return "" if jruby_opts.nil? # Only convert -Xa.b, -Xa.b.c, -Xa.b.c.d style options to properties properties = jruby_opts.scan(/-X(\w+\..+?)(\s|$)/) properties.map { |matches| "-Djruby.#{matches.first}" }.join(' ') end |
.modules_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
99 100 101 |
# File 'lib/torquebox/deploy_utils.rb', line 99 def modules_dir File.join( jboss_home, 'modules' ) end |
.normalize_archive_name(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
471 472 473 |
# File 'lib/torquebox/deploy_utils.rb', line 471 def normalize_archive_name(name) name[-5..-1] == '.knob' ? name : name + '.knob' end |
.normalize_yaml_name(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
467 468 469 |
# File 'lib/torquebox/deploy_utils.rb', line 467 def normalize_yaml_name(name) name[-9..-1] == '-knob.yml' ? name : name + '-knob.yml' end |
.opt_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used by upstart and launchd
58 59 60 |
# File 'lib/torquebox/deploy_utils.rb', line 58 def opt_dir File.join( sys_root, 'opt' ) end |
.opt_torquebox ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/torquebox/deploy_utils.rb', line 62 def opt_torquebox File.join( opt_dir, 'torquebox' ) end |
.package_gems(app_dir, package_without) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/torquebox/deploy_utils.rb', line 229 def package_gems(app_dir, package_without) # note - this is used instead of freeze gems because it # should cause the archive to capture .bundle/config, # thereby forcing the app to use the bundled gems. we delete # the deployment configuration for rubygems afterward bundler_config = File.join( app_dir, '.bundle/config' ) if File.exists?( bundler_config ) old_config = File.read( bundler_config ) else old_config = nil end cmd = %w{-S bundle --local --deployment} unless package_without.empty? cmd << '--without' cmd << package_without end Dir.chdir( app_dir ) do jruby_command( '-S bundle package --all' ) jruby_command( cmd.flatten.join(' ') ) end yield if block_given? ensure if File.exists?( bundler_config ) if old_config File.open( bundler_config, 'w' ) { |io| io.write( old_config ) } else File.delete( bundler_config ) # there wasn't originally a config file there end end end |
.precompile_assets(app_dir) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
223 224 225 226 227 |
# File 'lib/torquebox/deploy_utils.rb', line 223 def precompile_assets(app_dir) Dir.chdir( app_dir ) do jruby_command( "-S rake assets:precompile" ) end end |
.properties_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'lib/torquebox/deploy_utils.rb', line 87 def properties_dir config_dir end |
.readpartial(stream) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
455 456 457 |
# File 'lib/torquebox/deploy_utils.rb', line 455 def readpartial(stream) windows? ? stream.read(1) : stream.readpartial(1024) end |
.rubylib_with_bundler(load_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
523 524 525 526 527 528 529 530 |
# File 'lib/torquebox/deploy_utils.rb', line 523 def rubylib_with_bundler(load_path) bundler_load_paths = load_path.select { |p| p.include?('bundler') } rubylib = (ENV['RUBYLIB'] || '').dup # ENV strings are frozen unless rubylib.empty? || bundler_load_paths.empty? rubylib << ':' end rubylib << bundler_load_paths.join(':') end |
.run_command(cmd) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
385 386 387 388 389 390 391 392 393 |
# File 'lib/torquebox/deploy_utils.rb', line 385 def run_command(cmd) old_rubyopt = ENV['RUBYOPT'] begin ENV['RUBYOPT'] = '' puts `#{cmd} 2>&1` ensure ENV['RUBYOPT'] = old_rubyopt end end |
.run_command_line(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/torquebox/deploy_utils.rb', line 130 def run_command_line(opts={}) = ENV['JBOSS_OPTS'] || '' config_file = opts[:clustered] ? cluster_config_file : standalone_config_file = "#{} --server-config=#{config_file}" = "#{} -Dorg.torquebox.web.http.maxThreads=#{opts[:max_threads]}" if opts[:max_threads] = "#{} -b #{opts[:bind_address]}" if opts[:bind_address] = "#{} -Djboss.socket.binding.port-offset=#{opts[:port_offset]}" if opts[:port_offset] = "#{} -Dhttp.port=#{opts[:port]}" if opts[:port] = "#{} -Djboss.node.name=#{opts[:node_name]}" if opts[:node_name] = "#{} -Djboss.server.data.dir=#{opts[:data_directory]}" if opts[:data_directory] = "#{} -Dfile.encoding=UTF-8" if java.lang.System.getProperty('file.encoding') == 'MacRoman' = "#{} #{opts[:pass_through]}" if opts[:pass_through] if windows? cmd = "#{jboss_home.gsub('/', '\\')}\\bin\\standalone.bat" else cmd = "#{jboss_home}/bin/standalone.sh" end puts "#{cmd} #{}" # Make it clear to the user what is being passed through to JBoss AS [cmd, ] end |
.run_server(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/torquebox/deploy_utils.rb', line 155 def run_server(={}) puts "[WARNING] #{deployment_name} has not been deployed. Starting TorqueBox anyway." unless ( is_deployed? ) Dir.chdir(jboss_home) do # don't send the gemfile from the current app, instead let # bundler suss it out itself for each deployed # app. Otherwise, they'll end up sharing this Gemfile, which # is probably not what we want. ENV.delete('BUNDLE_GEMFILE') # If called from rake within a rails app, bundler will try # to init itself via RUBYOPT, which we don't want ENV.delete('RUBYOPT') # Ensure bundler gets on the Ruby load path of the booted # TorqueBox instance if it's on the load path of this Ruby # runtime so we can find bundler and our own gems if used # with bundle install --deployment ENV['RUBYLIB'] = rubylib_with_bundler($:) [:jvm_options] ||= '' [:jvm_options] << " #{jruby_opts_properties}" [:jvm_options] << " #{strip_jvm_properties_from_jruby_opts}" set_java_opts([:jvm_options].strip) print_server_config([:clustered]) exec_command(run_command_line().join(' ')) end end |
.server_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 |
# File 'lib/torquebox/deploy_utils.rb', line 66 def server_dir File.join("#{jboss_home}","#{jboss_conf}" ) end |
.set_java_opts(options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
125 126 127 128 |
# File 'lib/torquebox/deploy_utils.rb', line 125 def set_java_opts() ENV['JAVA_OPTS'] ||= "-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true" ENV['JAVA_OPTS'] = "#{ENV['JAVA_OPTS']} #{}" end |
.standalone_config_file ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/torquebox/deploy_utils.rb', line 74 def standalone_config_file eap? ? "torquebox-full.xml" : "standalone.xml" end |
.strip_jvm_properties_from_jruby_opts ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/torquebox/deploy_utils.rb', line 507 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, '') end end # get rid of any leftover spaces ENV['JRUBY_OPTS'] = ENV['JRUBY_OPTS'].split(' ').join(' ') jvm_properties.join(' ') end |
.sys_root ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: This is not windows friendly, is it?
53 54 55 |
# File 'lib/torquebox/deploy_utils.rb', line 53 def sys_root '/' end |
.torquebox_home ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 |
# File 'lib/torquebox/deploy_utils.rb', line 38 def torquebox_home torquebox_home = nil if ( ENV['TORQUEBOX_HOME'] ) torquebox_home = File.(ENV['TORQUEBOX_HOME']) else torquebox_home = TorqueBox::Server.torquebox_home end torquebox_home end |
.torquebox_modules_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 |
# File 'lib/torquebox/deploy_utils.rb', line 103 def torquebox_modules_dir File.join( modules_dir, 'system', 'layers', 'torquebox', 'org', 'torquebox' ) end |
.undeploy_archive(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
342 343 344 |
# File 'lib/torquebox/deploy_utils.rb', line 342 def undeploy_archive(opts = {}) undeploy( normalize_archive_name( find_option( opts, 'name' ) || archive_name( opts[:root] ) ), opts ) end |
.undeploy_yaml(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
346 347 348 |
# File 'lib/torquebox/deploy_utils.rb', line 346 def undeploy_yaml(opts = {}) undeploy( normalize_yaml_name( find_option( opts, 'name' ) || deployment_name( opts[:root] ) ), opts ) end |
.windows? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
459 460 461 |
# File 'lib/torquebox/deploy_utils.rb', line 459 def windows? RbConfig::CONFIG['host_os'] =~ /mswin/ end |