Skip to content

Instantly share code, notes, and snippets.

@jkutner
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkutner/7f1f271c579ebdab4c31 to your computer and use it in GitHub Desktop.
Save jkutner/7f1f271c579ebdab4c31 to your computer and use it in GitHub Desktop.
JRuby and Puma
Rails.application.config.after_initialize do
ActiveRecord::Base.connection_pool.disconnect!
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['MAX_PUMA_THREADS'] || 16
ActiveRecord::Base.establish_connection(config)
end
end
gem "puma", "2.10.2"
ruby '1.9.3', :engine => 'jruby', :engine_version => '1.7.16'
$ git add Procfile Gemfile
$ git commit -m "prepared app for heroku"
$ git init
$ git add .
$ git commit -am "first commit"
$ heroku create
Creating jkutner-test... done, stack is cedar-14
https://jkutner-test.herokuapp.com/ | https://git.heroku.com/jkutner-test.git
Git remote heroku added
$ git push heroku master
Counting objects: 34, done.
...
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-1.9.3-jruby-1.7.16
-----> Installing JVM: openjdk7-latest
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true
...
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (16.73s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true
I, [2014-12-04T20:09:48.558000 #970] INFO -- : Writing /tmp/build_4314fe0fe5c1c451df6755a9edded670/public/assets/application-3977927cf8f68a5ebafbe59011904fad.js
Asset precompilation completed (61.06s)
Cleaning assets
Running: rake assets:clean
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true
WARNING:
Include 'rails_12factor' gem to enable all platform features
See https://devcenter.heroku.com/articles/rails-integration-gems for more information.
-----> Discovering process types
Procfile declares types -> web
Default types for Ruby -> console, rake, worker
-----> Compressing... done, 112.5MB
-----> Launching... done, v7
https://jkutner-test.herokuapp.com/ deployed to Heroku
Verifying deploy... done.
To https://git.heroku.com/jkutner-test.git
7288c10..7814b0d master -> master
$ rvm use jruby-1.7.16.1
Using /Users/jkutner/.rvm/gems/jruby-1.7.16
$ ruby -v
jruby 1.7.16 (1.9.3p392) 2014-09-25 575b395 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_51-b13 +jit [darwin-x86_64]
web: bundle exec puma -C config/puma.rb
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
threads (ENV["MIN_PUMA_THREADS"] || 0), (ENV["MAX_PUMA_THREADS"] || 16)
preload_app!
$ bundle exec puma -C config/puma.rb
$ gem install rails -v 4.1.8
...
Successfully installed rails-4.1.8
1 gem installed
$ rails new my_app --database=postgresql
...
Use `bundle show [gemname]` to see where a bundled gem is installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment