Forum: JRuby warbler and trinidad

Posted by Rick F. (rickrails)
on 2012-11-21 16:04
Hello Jrubyists...

Is it possible to run Trinidad as the embedded web server in a warbler
created executable war file? If so, can someone point me in the right
direction? If not, how does one go about packaging up a Jruby rails app
that uses Trinidad as a standalone package (not necessarily a web
executable, but totally self-contained and portable)?

Can you specify where the war file extraction would go when kicking off
the execution? I would like to have it go to a specific directory versus
is putting it in some default location.

Finally, my database.yml will be configured depending on where it is
executed (installed) from based on the end users configuration. Can the
files inside the .war be easily accessed and modified if necessary? As
an example, lets say one of your controller files needs to be updated.
Does this imply a complete new .war needs to be created and distributed
or can one patch the .war? This question is not in a local debugging
context but with regard to a customer site(s).

Jruby is very impressive!

Thanks,
Rick
Posted by Joe Kutner (Guest)
on 2012-11-21 16:28
(Received via mailing list)
On Nov 21, 2012, at 9:04 AM, Rick F. wrote:

> Hello Jrubyists...
>
> Is it possible to run Trinidad as the embedded web server in a warbler
> created executable war file? If so, can someone point me in the right
> direction?

Not via the happy path.  In some ways, they both serve the same purpose 
and rely on jruby-rack to do the other stuff.


> If not, how does one go about packaging up a Jruby rails app
> that uses Trinidad as a standalone package (not necessarily a web
> executable, but totally self-contained and portable)?

You could deploy with Capistrano configure to deploy_via :copy -- that 
will package your app into tarball. But it wouldn't include Trinidad.

Trinidad and Warbler take two very different approaches to deployment. 
Warbler is the "package it all up in a single file" while Trinidad is 
typically used with Capistrano to deploy as loose files in a directory 
on the server.

>
> Can you specify where the war file extraction would go when kicking off
> the execution? I would like to have it go to a specific directory versus
> is putting it in some default location.

If I were to do this, I would explode the WAR file manually (its really 
just a ZIP file), and deploy it to my chosen Java Servlet Container with 
the appropriate context file.  But in general -- i wouldn't do that. 
For the most part, you should think of the contents of the WAR file as 
"compiled code" that you won't touch.  If you need to execute rake tasks 
and such, there is warbler-exec:
https://github.com/jkutner/warbler-exec

And I think someone forked that because I've heard mention of another 
solution that does the same thing (maybe better).

>
> Finally, my database.yml will be configured depending on where it is
> executed (installed) from based on the end users configuration. Can the
> files inside the .war be easily accessed and modified if necessary?

It would probably be best to externalize the database config so that it 
does not need to be stored in the WAR file.  I suspect there are 
patterns for this, but it's definitely outside the box.

> As
> an example, lets say one of your controller files needs to be updated.
> Does this imply a complete new .war needs to be created and distributed
> or can one patch the .war? This question is not in a local debugging
> context but with regard to a customer site(s).

Yes, its best to treat the WAR file as a binary file -- deploy all or 
none.  If you are very concerned about deploying in small bit, you might 
be able to transfer the new WAR with rsync or something.

In general, you'll need to pick between Warbler and Trinidad.  It comes 
down to which of these is more important to you:
- Deploying as a single portable file (Warbler)
- Deploying customized, small changes to customer sites (Trinidad)

I also recommend that you pick up my book, Deploying with Jruby -- i 
talk about these issues at length:
http://pragprog.com/book/jkdepj/deploying-with-jruby

You should also have a look at Torquebox.  It supports a Knob file 
deployment, which is similar to Warbler.  You might be able to get the 
best of both worlds this way.
Posted by Rick F. (rickrails)
on 2012-11-21 19:01
Thanks Joe, all good info.

I picked up the book...
Posted by Robin McKay (robin2)
on 2012-11-21 19:09
> Rick F. wrote in post #1085677:
> Hello Jrubyists...
>
> Is it possible to run Trinidad as the embedded web server in a warbler
> created executable war file?

> Jruby is very impressive!


Have you considered using Mizuno as your server? I think it is easier to
use than Trinidad - however I am not a professional programmer.

Rather than creating a War file with warbler you could create your JRuby
project in a directory structure that includes the JRuby interpreter
(and thus automatically includes and gems you install). Then if you copy
the entire directory structure to another PC with the JVM your project
should "just work".

You could also put your project into a .zip file to make it smaller and
then expand it on the other PC.
Posted by Dick Davies (Guest)
on 2012-11-22 11:55
(Received via mailing list)
Does that gain you a lot over

config.webserver = 'jetty'

in your warble.rb?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.