From vic.borja at gmail.com Wed Mar 5 14:58:45 2008 From: vic.borja at gmail.com (Victor Hugo Borja) Date: Wed, 5 Mar 2008 13:58:45 -0600 Subject: [Nailgun-users] Buildr's nailgun server running on JRuby Message-ID: <53466cf0803051158h4b75363dt9ee5c254a4655035@mail.gmail.com> Hi all, Just to tell you Buildr trunk now provides nailgun tasks when running within JRuby. Testers/comments are more than welcome. --- Current nailgun documentation follows --- Using BuildrServer(Buildr 1.3.0 (JRuby 1.1RC2), localhost, 2113) NailGun is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead. Nailgun integration is currently available only when running Buildr with JRuby. Buildr provides a custom nailgun server, allowing you to start a single JVM and let buildr create a queue of runtimes. These JRuby runtimes can be cached (indexed by buildfile path) and reloaded when the buildfile has been modified. Runtime caching allows you to execute tasks without spending time creating the buildr environment. Some nailgun tasks have been provided to manage the cached runtimes. To start the buildr server execute the ng:start task. Configuration and Environment Variables. Before starting the server, buildr will check if you have nailgun already installed by seeking the nailgun jar under $NAILGUN_HOME You can override this environment variable to tell buildr where to find or where to install nailgun. If missing, NAILGUN_HOME defaults to the $JRUBY_HOME/tools/nailgun directory. You can also specify the nailgun_home on your buildfile with the following code: require 'java/nailgun' Buildr::Nailgun.home = File.expand_path('~/.jruby/tools/nailgun') Buildr will also check that the nailgun client binary (ng.exe for Windows systems, ng otherwise) is installed on NAILGUN_HOME. If no binary is found, buildr will download nailgun and compile+install it. The buildr server binds itself to localhost, port 2113. You can override this on your buildfile, by placing the following code: require 'java/nailgun' Buildr::Nailgun.server = '127.0.0.1' Buildr::Nailgun.port = 2233 Once started, if you provided custom host/port settings you need to tell the nailgun client where to connect to: ng --nailgun-server 127.0.0.1 --nailgun-port 2233 ng:tasks The buildr server starts a BuildrFactory responsible for providing a pool of JRuby runtimes configured and ready for task execution. This BuildrFactory consists of two queues: One of pure JRuby runtimes with almost nothing loaded, and another of Buildr runtimes (consumed from the first queue) with the Buildr runtime preloaded but without any project definition. The jruby queue is used for sandboxing code like running GetoptLong, but most importantly its the place where buildr runtimes begin life, to be later added on the buildr queue. By default both queues are of size 3, you can customize this with: require 'java/nailgun' Buildr::Nailgun.jruby_queue_size = 4 # JRuby creation is fast! Buildr::Nailgun.buildr_queue_size = 5 # loading buildr takes longer The buildr_queue_size is of particular importance if you expect to reload lots of buildfiles. Execute ng:tasks get an overview of available nailgun tasks. Nailgun tasks: ng:help Display nailgun help ng:start Start the Nailgun server. ng:stop Stop the Nailgun server. ng:tasks Display this message ng:list Display a list of builfile paths having an associated buildr runtime. Having a cached runtime reduces buidlr execution time. If buildr finds the current buildfile on this list, no file loading will be performed, only execution of specified tasks on the previously loaded environment. However if the cached runtime is out of date (buildfile has been modified) the runtime will be reloaded. This feature becomes handy when performing development cycle: edit -> compile -> test -> report. This task exits inmediatly after printing the file list. ng:clear Remove all cached buildr runtimes and exit ng:add [tasks] | ng:put [tasks] Add or update a cached runtime. Use this task to create a cached buildr runtime for a buildfile. ng:del | ng:delete Delete cached runtime for a buildfile and exit. ng:once [tasks] Ignore cached runtime and perform tasks on a newly created environment. This new runtime is dropped right after buildr completion. -- vic Quaerendo invenietis. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.martiansoftware.com/pipermail/nailgun-users_martiansoftware.com/attachments/20080305/432ce88b/attachment.html From charles.nutter at sun.com Wed Mar 5 15:33:40 2008 From: charles.nutter at sun.com (Charles Oliver Nutter) Date: Wed, 05 Mar 2008 14:33:40 -0600 Subject: [Nailgun-users] Buildr's nailgun server running on JRuby In-Reply-To: <53466cf0803051158h4b75363dt9ee5c254a4655035@mail.gmail.com> References: <53466cf0803051158h4b75363dt9ee5c254a4655035@mail.gmail.com> Message-ID: <47CF03A4.9050500@sun.com> Victor Hugo Borja wrote: > Hi all, > > Just to tell you Buildr trunk now provides nailgun tasks when running > within JRuby. > Testers/comments are more than welcome. Wow, cool. Have you looked at what we provide in JRuby proper? Basically if you pull JRuby sources and "ant jruby-nailgun" you can use a jruby-ng-server and jruby-ng commands to run JRuby as normal. There seems to be some overlap...so we should figure out how to share some code going forward. - Charlie From vic.borja at gmail.com Wed Mar 5 16:18:16 2008 From: vic.borja at gmail.com (Victor Hugo Borja) Date: Wed, 5 Mar 2008 15:18:16 -0600 Subject: [Nailgun-users] Buildr's nailgun server running on JRuby In-Reply-To: <47CF03A4.9050500@sun.com> References: <53466cf0803051158h4b75363dt9ee5c254a4655035@mail.gmail.com> <47CF03A4.9050500@sun.com> Message-ID: <53466cf0803051318x12240129y304dae0777475778@mail.gmail.com> Charlie, On Wed, Mar 5, 2008 at 2:33 PM, Charles Oliver Nutter < charles.nutter at sun.com> wrote: > Wow, cool. Have you looked at what we provide in JRuby proper? Basically > if you pull JRuby sources and "ant jruby-nailgun" you can use a > jruby-ng-server and jruby-ng commands to run JRuby as normal. > Yeah, I know of jruby-nailgun, however I think most jruby users would normally download the standard jruby binary distribution ( I currently have 1.1RC2 ) and it comes without nailgun. Anyway, that's why buildr's default NAILGUN_HOME points to $JRUBY_HOME/tools/nailgun, so that if buildr finds nailgun jar/executable already there, it wont download/compile/install nailgun. > There seems to be some overlap...so we should figure out how to share > some code going forward. > I also read JRuby's nail code :) Buildr implements a custom nailgun server, and a queue of jruby runtimes, so when a nail-client connects, it just takes an already initialized (preloaded buildr with all required gems) runtime and just executes the tasks. Best of all it's all in ruby, and uses lots of JRuby's features. Here's the current implementation if you want to take a look, the BuildrNail, BuildrServer, BuildrFactory classes are the most relevant: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/org/apache/buildr/BuildrNail.java?view=markup http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/nailgun.rb?view=markup Cheers, -- vic Quaerendo invenietis. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.martiansoftware.com/pipermail/nailgun-users_martiansoftware.com/attachments/20080305/1db32963/attachment.html