Running several jetty instances in different subprojects

2009-07-20 Thread Martin Grotzke
Hi,

our project contains several subprojects. Two of them I want to run with
jetty, both instances shall be running at the same time.

To change the port for one of the instances, I use
  jetty.url = http://localhost:8090;
in the context of one subproject, but this seems to change also the url
for the jetty task defined in the different subproject.

That's how I define the jetty tasks:

define myproj do

  define subprojA do
...
task(jetty=[package(:war), jetty.use]) do |task|
  jetty.deploy(http://localhost:8080;, task.prerequisites.first)
  puts 'Press CTRL-C to stop Jetty'
  trap 'SIGINT' do
jetty.stop
  end
  Thread.stop
end

  end

  define subprojB do

jetty.url = http://localhost:8090;
task(jetty=[package(:war), jetty.use]) do |task|
  jetty.deploy(http://localhost:8090;, task.prerequisites.first)
  puts 'Press CTRL-C to stop Jetty'
  trap 'SIGINT' do
jetty.stop
  end
  Thread.stop
end

  end

end

When I run the first jetty with
  buildr myproj:subprojA
it fails with
...
Starting Jetty at http://localhost:8090
1 [main] INFO org.mortbay.log - Logging to 
org.slf4j.impl.SimpleLogger(org.mortbay.log) via org.mortbay.log.Slf4jLog
15 [main] INFO org.mortbay.log - jetty-6.1.3
74 [main] INFO org.mortbay.log - Started SocketConnector @ 0.0.0.0:8090
Jetty started
Buildr aborted!
Connection refused - connect(2)


Is it somehow possible to run several jetty instances for different
subprojects?


Thanx  cheers,
Martin



signature.asc
Description: This is a digitally signed message part


Re: Running several jetty instances in different subprojects

2009-07-20 Thread Assaf Arkin
On Mon, Jul 20, 2009 at 8:57 AM, Martin Grotzke 
martin.grot...@javakaffee.de wrote:

 Hi,

 our project contains several subprojects. Two of them I want to run with
 jetty, both instances shall be running at the same time.

 To change the port for one of the instances, I use
  jetty.url = http://localhost:8090;
 in the context of one subproject, but this seems to change also the url
 for the jetty task defined in the different subproject.

 That's how I define the jetty tasks:

 define myproj do

  define subprojA do
...
task(jetty=[package(:war), jetty.use]) do |task|
  jetty.deploy(http://localhost:8080;, task.prerequisites.first)
  puts 'Press CTRL-C to stop Jetty'
  trap 'SIGINT' do
jetty.stop
  end
  Thread.stop
end

  end

  define subprojB do

jetty.url = http://localhost:8090;
task(jetty=[package(:war), jetty.use]) do |task|
  jetty.deploy(http://localhost:8090;, task.prerequisites.first)
  puts 'Press CTRL-C to stop Jetty'
  trap 'SIGINT' do
jetty.stop
  end
  Thread.stop
end

  end

 end

 When I run the first jetty with
  buildr myproj:subprojA
 it fails with
 ...
 Starting Jetty at http://localhost:8090
 1 [main] INFO org.mortbay.log - Logging to
 org.slf4j.impl.SimpleLogger(org.mortbay.log) via org.mortbay.log.Slf4jLog
 15 [main] INFO org.mortbay.log - jetty-6.1.3
 74 [main] INFO org.mortbay.log - Started SocketConnector @ 0.0.0.0:8090
 Jetty started
 Buildr aborted!
 Connection refused - connect(2)


 Is it somehow possible to run several jetty instances for different
 subprojects?


Each time you call the jetty method it will return the same one instance of
jetty.  The jetty task is run after the buildfile, at which point the last
value you set to jetty.url is the current value, which happens to be 8090.

If you want multiple instances, Jetty.new(name, url) and give each one a
different URL.  Name is used to namespace the setup/teardown/use task, so
you can use the same name for all instances, or pick different one.

Assaf




 Thanx  cheers,
 Martin