mina-deploy / mina

Blazing fast deployer and server automation tool
https://rubygems.org/gems/mina
Other
4.36k stars 491 forks source link

[Bug] Precompile Assets with JRuby #29

Closed mrrooijen closed 11 years ago

mrrooijen commented 12 years ago

Trying to deploy through JRuby using the provided bundle:install task.

-----> Using revision origin/master
-----> Installing gem dependencies using Bundler
       Using rake (0.9.2.2) 
       Using i18n (0.6.0) 
       Using multi_json (1.3.6) 
       Using activesupport (3.2.6) 
       Using builder (3.0.0) 
       Using activemodel (3.2.6) 
       Using erubis (2.7.0) 
       Using journey (1.0.4) 
       Using rack (1.4.1) 
       Using rack-cache (1.2) 
       Using rack-test (0.6.1) 
       Using hike (1.2.1) 
       Using tilt (1.3.3) 
       Using sprockets (2.1.3) 
       Using actionpack (3.2.6) 
       Using mime-types (1.19) 
       Using polyglot (0.3.3) 
       Using treetop (1.4.10) 
       Using mail (2.4.4) 
       Using actionmailer (3.2.6) 
       Using arel (3.0.2) 
       Using tzinfo (0.3.33) 
       Using activerecord (3.2.6) 
       Using activeresource (3.2.6) 
       Using addressable (2.2.7) 
       Using coffee-script-source (1.3.1) 
       Using execjs (1.3.0) 
       Using coffee-script (2.2.0) 
       Using eco-source (1.1.0.rc.1) 
       Using eco (1.0.0) 
       Using ejs (1.0.0) 
       Using rack-ssl (1.3.2) 
       Using json (1.7.3) 
       Using rdoc (3.12) 
       Using thor (0.15.4) 
       Using railties (3.2.6) 
       Using jquery-rails (2.0.2) 
       Using backbone-on-rails (0.9.2.0) 
       Using backbone-support (0.2.0) 
       Using bcrypt-ruby (3.0.1) 
       Using bootstrap-sass (2.0.2) 
       Using bson (1.6.4) 
       Using bson_ext (1.6.2) 
       Using celluloid (0.10.0) 
       Using multi_xml (0.4.4) 
       Using httparty (0.8.2) 
       Using cheddargetter_client_ruby (0.3.2) 
       Using chunky_png (1.2.5) 
       Using clockwork (0.4.0) 
       Using coderay (1.0.6) 
       Using coffee-rails (3.2.2) 
       Using fssm (0.2.9) 
       Using sass (3.1.15) 
       Using compass (0.12.1) 
       Using compass-rails (1.0.1) 
       Using connection_pool (0.9.1) 
       Using crack (0.3.1) 
       Using draper (0.11.1) 
       Using term-ansicolor (1.0.7) 
       Using foreman (0.39.0) 
       Using gibberish (1.2.0) 
       Using haml (3.1.4) 
       Using haml-rails (0.3.4) 
       Using launchy (2.1.0) 
       Using netrc (0.7.1) 
       Using rest-client (1.6.7) 
       Using rubyzip (0.9.7) 
       Using heroku (2.24.1) 
       Using method_source (0.7.1) 
       Using mongo (1.6.2) 
       Using mongoid (2.4.11) 
       Using parallel (0.5.16) 
       Using slop (2.4.4) 
       Using pry (0.9.8.4) 
       Using puma (1.4.0) 
       Using rabl (0.6.10) 
       Using rack-protection (1.2.0) 
       Using bundler (1.1.4) 
       Using rails (3.2.6) 
       Using redis (2.2.2) 
       Using redis-namespace (1.1.0) 
       Using sass-rails (3.2.5) 
       Using sidekiq (1.2.0) 
       Using sinatra (1.3.2) 
       Using temple (0.3.5) 
       Using slim (1.0.4) 
       Using uglifier (1.2.4) 
       Your bundle is complete! 
-----> Precompiling asset files
       Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
       materialize at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90
       map! at org/jruby/RubyArray.java:2382
       materialize at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/spec_set.rb:83
       specs at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/definition.rb:127
       specs_for at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/definition.rb:172
       requested_specs at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/definition.rb:161
       requested_specs at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/environment.rb:23
       setup at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:11
       setup at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler.rb:107
       (root) at /home/deployer/.rvm/gems/jruby-1.7.0.preview1@global/gems/bundler-1.1.4/lib/bundler/setup.rb:17
       require at org/jruby/RubyKernel.java:991
       (root) at /home/deployer/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:1
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK

 !     Command failed.
       Failed with status 19

It keeps saying it can't find certain gems during the precompile stage. Any idea why?

mrrooijen commented 12 years ago

The following command does work:

queue "jruby -S bundle install --without development:test"

I don't use the --deployment flag because it seems to re-install all the gems and seems slow. Installing them without the flag re-uses them on every deploy instantly without re-installing. Though copying over the whole line from the bundle:install helper but prefixing it with jruby -S also solves the issue. So it's not a blocker for me, but good to know for other people on JRuby experiencing the issue.

rstacruz commented 12 years ago

Can anyone help debug why this happens? bundle install --deployment should technically be fine and just as fast (if not faster) than without it.

rstacruz commented 12 years ago

Anyway, the better fix would be to set the options for Bundler like so:

set :bundle_bin, "jruby -S bundle"
set :bundle_options, "--without development:test"

This way you don't need to make your own bundle:install task.

rstacruz commented 12 years ago

That commit above will also make other commands (like rails:assets_precompile) respect the bundle_bin setting, making them run tasks as jruby -S bundle exec rake db:migrate.

mrrooijen commented 12 years ago

Ah. Sorry I forgot to mention that I actually forgot I had to set the --path. I just pointed the --path to shared/vendor/bundle and the deployments are now fast. Since I forgot to set it, it was re-installing it over and over again.

The current command I am using works fine with JRuby:

queue "jruby -S bundle install --without development:test " +
      "--deployment --binstubs ./bin --path #{deploy_to}/#{shared_path}/vendor/bundle"

I don't get any issues any longer, and --binstubs are pretty much a must since bundle exec in JRuby should be avoided as JRuby doesn't play nice with forking processes. Example Procfile:

web: source ~/.bashrc; ./bin/trinidad -p $PORT
processor: source ~/.bashrc; ./bin/sidekiq -c 100 -q default
service: source ~/.bashrc; ./bin/clockwork services.rb

Without prefixing the commands with bundle exec.

The only thing that's still incredibly slow is the asset pipeline, mostly because of JRuby again. So the other issue where assets are being re-compiled when unnecessary would of course be a great help if no front-end related code has changed. Then deployments should be done in a few seconds. JRuby with asset pipeline takes like 90% of the time unfortunately. Which leads up to 90 second deployments.

mikong commented 11 years ago

Looks like there's no issue left here. The other problem (about unnecessary re-compile of assets) has been fixed (#25).