buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Assaf Arkin <ar...@intalio.com>
Subject Re: How to run a webapp in jetty
Date Tue, 17 Feb 2009 06:42:37 GMT
On Mon, Feb 16, 2009 at 1:07 AM, Martin Grotzke <
martin.grotzke@javakaffee.de> wrote:

> On Sun, 2009-02-15 at 16:07 -0800, Assaf Arkin wrote:
> > On Sun, Feb 15, 2009 at 8:26 AM, Martin Grotzke <
> > martin.grotzke@javakaffee.de> wrote:
> >
> > > Hi Assaf,
> > >
> > > would you say [1] is the right way to run a webapp in jetty, or is
> there
> > > a better way?
> >
> >
> > I personally don't like the build to block, I like to have the shell
> ready
> > while the server is running in the background, so I recommend using
> > jetty:start.
> Ok. Do you have a complete example so that we could add this to the
> buildr+jetty howto?


Adapted from your example:

task("deploy-app"=>[package(:war), jetty.use]) do |task|
   class << task ; attr_accessor :url, :path ; end
   task.url = "http://localhost:8080/mywebapp"
   task.path = jetty.deploy(task.url, task.prerequisites.first)
end

I renamed the task deploy-app instead of start, and remove the stopping
part.

Now, in one console do:

$ buildr jetty:start

Switch to a different console and do:

$ buildr deploy-app

Now the app is running and you can access it from the browser. The first
console is effectively the Jetty log, and you kill Jetty at any time by
going there and hitting Ctrl-C. The second console gives you a new prompt
and you can run buildr deploy-app again, test the app using curl, etc.


Alternatively, in a single console:

$ buildr jetty:start &
$ buildr deploy-app

And again this free up the console so you can do more work while your app is
running inside Jetty. To stop the server:

$ buildr jetty:stop

Assaf


>
> Cheers,
> Martin
>
>
> >
> > Assaf
> >
> >
> > >
> > >
> > > Cheers,
> > > Martin
> > >
> > >
> > > [1] http://cwiki.apache.org/confluence/display/BUILDR/How+to+run+jetty
> > >
> > >
> > >
> > > On Sun, 2009-02-15 at 01:40 -0800, Assaf Arkin wrote:
> > > > On Fri, Feb 13, 2009 at 5:37 PM, Martin Grotzke <
> > > > martin.grotzke@javakaffee.de> wrote:
> > > >
> > > > > Hi Daniel,
> > > > >
> > > > > thanx for your fast reply! At javaworld I found one relevant
> article
> > > > > ([1]), but this does only show (at least AFAICS) how to start jetty
> > > > > programmatically from java - what's not what I'm looking for. Am
I
> > > > > missing s.th. in this article?
> > > >
> > > >
> > > > buildr jetty:start
> > > >
> > > > This will start Jetty running in the current shell, and you can kill
> it
> > > with
> > > > Ctrl-C, or buildr jetty:stop (from a different shell). And of course
> you
> > > can
> > > > have your build finish by invoking this task (e.g. after packaging
> and
> > > > deploying the web app).
> > > >
> > > > If the build does jetty:use, it either uses the running instance, or
> if
> > > > there is no instance, starts a new one and shut it down at the end
> > > (useful
> > > > for integration tests).
> > > >
> > > > Assaf
> > > >
> > > >
> > > > >
> > > > >
> > > > > Thx && cheers,
> > > > > Martin
> > > > >
> > > > >
> > > > > [1]
> > > > >
> > >
> http://www.javaworld.com/javaworld/jw-12-2007/jw-12-outside-the-ide.html
> > > > >
> > > > >
> > > > > On Fri, 2009-02-13 at 19:04 -0600, Daniel Spiewak wrote:
> > > > > > Nathan Hamblin has created a Buildr extension which accomplished
> > > > > > this.  I don't have a URL handy, but he did publish it in a
> JavaWorld
> > > > > > article.
> > > > > >
> > > > > > Daniel
> > > > > >
> > > > > > On Feb 13, 2009, at 6:37 PM, Martin Grotzke <
> > > > > martin.grotzke@javakaffee.de
> > > > > >  > wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have a simple webapp and want to run this with jetty.
> > > > > > >
> > > > > > > Just running "buildr jetty:start" (with require 'buildr/jetty'
> in
> > > my
> > > > > > > buildfile) starts jetty, but then jetty doesn't serve my
> webapp.
> > > > > > >
> > > > > > > From the ode buildfile I found the following:
> > > > > > >
> > > > > > >  task("start"=>[package(:war), jetty.use]) do |task|
> > > > > > >    class << task ; attr_accessor :url, :path ; end
> > > > > > >    task.url = "http://localhost:8080/mywebapp"
> > > > > > >    task.path = jetty.deploy(task.url, task.prerequisites.first)
> > > > > > >    jetty.teardown task("stop")
> > > > > > >  end
> > > > > > >
> > > > > > >  task("stop") do |task|
> > > > > > >    if url = task("start").url rescue nil
> > > > > > >      jetty.undeploy url
> > > > > > >    end
> > > > > > >  end
> > > > > > >
> > > > > > > It seems that I can invoke this with "buildr
> > > > > > > mywebapp:start" ("mywebapp"
> > > > > > > beeing the name I defined for my project). I see jetty
starting
> my
> > > > > > > webapp, but unfortunately it stops directly afterwards.
This is
> the
> > > > > > > end
> > > > > > > of the output:
> > > > > > >
> > > > > > > ====================
> > > > > > > [Completed] Your build has completed:
> /home/grotzke/proj/mywebapp
> > > > > > > buildr mywebapp:start
> > > > > > > Completed in 2.625s
> > > > > > > Undeploying app at /mywebapp
> > > > > > > Jetty server stopped
> > > > > > > ====================
> > > > > > >
> > > > > > > So what is the correct way to run jetty with the deployed
> webapp?
> > > > > > >
> > > > > > > Thanx in advance,
> > > > > > > cheers,
> > > > > > > Martin
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message