JRuby and Joyent Accelerators
Posted on May 27, 2007
I don’t pimp Joyent products much, but I’ll do so for this one. In our new Joyent Accelerators JRuby is pre-installed and ready to run out of the box. Joyent is a key player in the Ruby on Rails world, hosting some of the biggest (Twitter) and best (Ebible) Rails sites on the net. I’m glad to say that we’re the first hosting company to get behind and seriously advocate JRuby for production use.
Getting started is easy. In our Accelerators you’ll JRuby 1.0.0RC2 in /opt/jruby. JRuby comes complete with the jruby interpreter which is used just like ruby, including friends like gem, jirb, and more. Lets take a look at how to get started:
[z010101CA:~] admin$ export PATH=/opt/jruby/bin:$PATH [z010101CA:~] admin$ jirb irb(main):001:0> string = 'JRuby Rules\!' => "JRuby Rules\\!" irb(main):002:0> print string JRuby Rules\!=> nil irb(main):003:0> string.upcase => "JRUBY RULES\\!" irb(main):004:0> quit
Its really just that simple. Want to do some JRuby on Rails work?
[z010101CA:~] admin$ which gem gem is /opt/jruby/bin/gem [z010101CA:~] admin$ gem list --local *** LOCAL GEMS *** sources (0.0.1) This package provides download sources for remote gem installation [z010101CA:~] admin$ sudo gem install rails -y Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed rails-1.2.3 Successfully installed rake-0.7.3 Successfully installed activesupport-1.4.2 Successfully installed activerecord-1.15.3 Successfully installed actionpack-1.13.3 Successfully installed actionmailer-1.3.3 Successfully installed actionwebservice-1.2.3 ... [z010101CA:~] admin$ sudo chmod +r /opt/jruby/bin/* Password: [z010101CA:~] admin$ which rails rails is hashed (/opt/jruby/bin/rails) [z010101CA:~] admin$ rails webstore create create app/controllers create app/helpers ........ [z010101CA:~] admin$ cd webstore/ [z010101CA:~/webstore] admin$ jruby script/server => Booting WEBrick... => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2007-05-27 07:00:52] INFO WEBrick 1.3.1 [2007-05-27 07:00:52] INFO ruby 1.8.5 (2007-05-16) [java] [2007-05-27 07:00:52] INFO WEBrick::HTTPServer#start: pid=33409388 port=3000 24.6.105.152 - - [27/May/2007:07:01:20 GMT] "GET / HTTP/1.1" 200 7552 - -> / 24.6.105.152 - - [27/May/2007:07:01:20 GMT] "GET /javascripts/prototype.js HTTP/1.1" 200 71260 http://8.12.34.20:3000/ -> /javascripts/prototype.js 24.6.105.152 - - [27/May/2007:07:01:20 GMT] "GET /javascripts/effects.js HTTP/1.1" 200 38200 http://8.12.34.20:3000/ -> /javascripts/effects.js 24.6.105.152 - - [27/May/2007:07:01:21 GMT] "GET /images/rails.png HTTP/1.1" 200 1787 http://8.12.34.20:3000/ -> /images/rails.png 24.6.105.152 - - [27/May/2007:07:01:21 GMT] "GET /favicon.ico HTTP/1.1" 200 0 - -> /favicon.ico ...
Its that simple. No tricks, no gimmicks. Just start playing.
In particular, we’re excited about the plethora of mature Java features that can be brought into the Rails world, including JDBC and real threading.
For those who don’t have a Joyent Accelerator, download JRuby here: JRuby.org.