File: jruby.rb

package info (click to toggle)
ruby-aruba 2.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 968 kB
  • sloc: javascript: 6,850; ruby: 4,010; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'rbconfig'

# ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
Aruba.configure do |config|
  config.before :command do |command|
    next unless RUBY_PLATFORM == 'java'

    env = command.environment

    jruby_opts = env['JRUBY_OPTS'] || ''

    # disable JIT since these processes are so short lived
    jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? '-X-C'

    # Faster startup for jruby
    jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? '--dev'

    env['JRUBY_OPTS'] = jruby_opts

    if /solaris|sunos/i.match?(RbConfig::CONFIG['host_os'])
      java_opts = env['JAVA_OPTS'] || ''

      # force jRuby to use client JVM for faster startup times
      env['JAVA_OPTS'] = "-d32 #{java_opts}" unless java_opts.include?('-d32')
    end
  end
end