In part inspired by Sinclair Bain's presentation on JRuby and in-part inspired by the lateness that I returned home from said meeting, I think that I will try to get my Sinatra application running under JRuby. Specifically, I would like to get it running under glassfish (with the glassfish gem)
The first thing that will be require is JRuby itself. On my Debian VM:
sudo apt-get install jruby1.2That takes a long because of the sheer number of dependencies
I install some gems that I know that I am going to need:
cstrom@debian:~$ jruby -S gem install sinatraI am going to need my couch_docs gem as well, so I need to add Githib to my gem sources:
cstrom@debian:~$ jruby -S gem install glassfish
cstrom@debian:~$ jruby -S gem install json-jruby
cstrom@debian:~$ jruby -S gem sources -a http://gems.github.comAnd then try to install the gem:
cstrom@debian:~$ jruby -S gem install eee-c-couch_docsAw, nuts! I need to figure out how to make my gem dependent on json-jruby or plain old json. On top of that, Pony (for sending email) is also not available on JRuby (pony-gae seems to be a drop-in replacement).
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
WARNING: Installing to ~/.gem since /usr/lib/jruby1.2/lib/ruby/gems/1.8 and
/usr/lib/jruby1.2/bin aren't both writable.
WARNING: You don't have /home/cstrom/.gem/jruby/1.8/bin in your PATH,
gem executables will not run.
Building native extensions. This could take a while...
/usr/lib/jruby1.2//lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError)
from /usr/lib/jruby1.2//lib/ruby/1.8/mkmf.rb:1:in `require'
from extconf.rb:1
ERROR: Error installing eee-c-couch_docs:
ERROR: Failed to build gem native extension.
/usr/lib/jruby1.2/bin/jruby extconf.rb install eee-c-couch_docs
Gem files will remain installed in /home/cstrom/.gem/jruby/1.8/gems/json-1.1.7 for inspection.
Results logged to /home/cstrom/.gem/jruby/1.8/gems/json-1.1.7/ext/json/ext/generator/gem_make.out
The combination of those two non-supported gems are enough to defeat me tonight. Still, I would like to get the whole stack of Sinatra / Couch running on the VM. First, I create my CouchDB database:
curl -X PUT http://localhost:5984/eeeWhen trying to run my rake tasks to load the CouchDB design documents, it becomes apparent that I need to install rake:
sudo apt-get install rakeI also have to edit my
Rakefile
to require rubygems (not sure why that is not necessary on my local desktop) and to rename CouchDesignDocs to CouchDocs (need to double check that I do not have local changes queued up tomorrow).Once I have my edited Rakefile, I can load my design documents:
cstrom@debian:~/repos/eee-code$ rake couchdb:load_design_docsBefore I can get the application to start, I need to install the Pony, RedCloth, and Haml gems. With that, I finally get:
cstrom@debian:~/repos/eee-code$ ruby eee.rbAnd:
== Sinatra/0.9.4 has taken the stage on 4567 for development with backup from WEBrick
[2009-08-11 19:47:17] INFO WEBrick 1.3.1
[2009-08-11 19:47:17] INFO ruby 1.8.7 (2009-06-12) [i486-linux]
[2009-08-11 19:47:17] INFO WEBrick::HTTPServer#start: pid=20430 port=4567
Nice. I have some work to do in the Rakefile tomorrow. I also need to consolidate my installation notes. Still, it is nice to know that I get the application up and running in a VM so quickly.
Try depending on json_pure.gem which is a pure ruby version of the json.gem.
ReplyDeletePS: I love this series!
ReplyDeleteYou should think about approaching the Pragmatic Programmers about turning your blog posts into a book - I'd buy it!
I may do that. The only place that I *really* need the json gem in couch_docs is assembling design documents from the .js files. That is a one-time hit, meaning that json-pure would not adversely affect things.
ReplyDeleteI've seen other people alter gems to not have a gem dependency on JSON, but to check for it at compile time. That's ugly, but do-able as well.
Thanks for the kinds words. It really is energizing to get feedback like that!