You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Ian Nowland <ia...@gmail.com> on 2011/07/27 21:29:09 UTC
Java Processes
I've got a buildr/jetty/jersey setup I've been playing around with (that
took an annoyingly long time to get configured) which is working pretty much
as I would like it to, except for that the process seems to kick off on it's
own, meaning I can't see console output and I have to kill -9 it whenever I
want it to stop. I'm setting it off with a pretty typical:
task :run => :compile do
puts('Starting up with classpath ' + compile.dependencies.to_s + " "
+ [compile.target.to_s].to_s)
Java::Commands.java('launcher.
MyServer', :classpath => compile.dependencies + [compile.target.to_s])
end
And then in launcer.MyServer.scala
object MyServer {
def main(args: Array[String]) {
System.out.println("Starting up server")
val server = new Server(8080)
val connector = new SelectChannelConnector()
server.addConnector(connector)
val holder:ServletHolder = new ServletHolder(classOf[ServletContainer])
holder.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig")
holder.setInitParameter("com.sun.jersey.config.property.packages",
"com.sample")
val context = new ServletContextHandler(server, "/",
ServletContextHandler.SESSIONS)
context.addServlet(holder, "/*")
server.start
server.join
}
}
When I 'buildr run', while things seem to start up fine, I never see the
"Starting up server" line. When I kill the buildr:run with a ctrl-c, as I
mentioned before, the server stays alive.
What's a more manageable way to launch the process?
For bonus points, the documentation is a little sparse on suggestions for
how to package my code into something a bit more publishable/distributable
(which I realize is really a general problem that applies to all build
tools...still, it'd be nice). Are there any suggestions for how to tie a bow
around this system, or is the best thing to do really just to jar it up,
with a script that does a java -jar?
Thanks,
Ian
Re: Java Processes
Posted by Ian Nowland <ia...@gmail.com>.
I was out of town for a few days, and then the amazon instance my code was
on crashed and I had to recover. Anyhow, it looks like Apache's JIRA for
buildr doesn't allow file uploading, but I pasted my code into the bug:
https://issues.apache.org/jira/browse/BUILDR-607
--Ian
On Fri, Aug 5, 2011 at 1:33 PM, Antoine Toulme <an...@lunar-ocean.com>wrote:
> Please, that would certainly help!
>
> Antoine
>
> On Fri, Aug 5, 2011 at 07:41, Ian Nowland <ia...@gmail.com> wrote:
>
> > Do you want me to file an issue, and upload the code I have that produces
> > this?
> >
> > --Ian
> >
> > On Thu, Jul 28, 2011 at 10:16 AM, Alex Boisvert <alex.boisvert@gmail.com
> > >wrote:
> >
> > > On Wed, Jul 27, 2011 at 12:29 PM, Ian Nowland <ia...@gmail.com>
> > > wrote:
> > >
> > > > I've got a buildr/jetty/jersey setup I've been playing around with
> > (that
> > > > took an annoyingly long time to get configured) which is working
> pretty
> > > > much
> > > > as I would like iht to, except for that the process seems to kick off
> > on
> > > > it's
> > > > own, meaning I can't see console output and I have to kill -9 it
> > whenever
> > > I
> > > > want it to stop. I'm setting it off with a pretty typical:
> > > >
> > >
> > > Hmmm. I can't reproduce this with a simple Java main program. Output
> > goes
> > > to stdout (as expected) and Ctrl-C kills both the buildr and the java
> > main
> > > processes.
> > >
> > > task :run => :compile do
> > > > puts('Starting up with classpath ' + compile.dependencies.to_s
> +
> > "
> > > "
> > > > + [compile.target.to_s].to_s)
> > > > Java::Commands.java('launcher.
> > > > MyServer', :classpath => compile.dependencies +
> [compile.target.to_s])
> > > > end
> > > >
> > >
> > > By the way, there is a standard run task since Buildr 1.4.5 that may
> save
> > > you some keystrokes,
> > >
> > > http://buildr.apache.org/more_stuff.html#run
> > >
> > > alex
> > >
> >
>
Re: Java Processes
Posted by Antoine Toulme <an...@lunar-ocean.com>.
Please, that would certainly help!
Antoine
On Fri, Aug 5, 2011 at 07:41, Ian Nowland <ia...@gmail.com> wrote:
> Do you want me to file an issue, and upload the code I have that produces
> this?
>
> --Ian
>
> On Thu, Jul 28, 2011 at 10:16 AM, Alex Boisvert <alex.boisvert@gmail.com
> >wrote:
>
> > On Wed, Jul 27, 2011 at 12:29 PM, Ian Nowland <ia...@gmail.com>
> > wrote:
> >
> > > I've got a buildr/jetty/jersey setup I've been playing around with
> (that
> > > took an annoyingly long time to get configured) which is working pretty
> > > much
> > > as I would like iht to, except for that the process seems to kick off
> on
> > > it's
> > > own, meaning I can't see console output and I have to kill -9 it
> whenever
> > I
> > > want it to stop. I'm setting it off with a pretty typical:
> > >
> >
> > Hmmm. I can't reproduce this with a simple Java main program. Output
> goes
> > to stdout (as expected) and Ctrl-C kills both the buildr and the java
> main
> > processes.
> >
> > task :run => :compile do
> > > puts('Starting up with classpath ' + compile.dependencies.to_s +
> "
> > "
> > > + [compile.target.to_s].to_s)
> > > Java::Commands.java('launcher.
> > > MyServer', :classpath => compile.dependencies + [compile.target.to_s])
> > > end
> > >
> >
> > By the way, there is a standard run task since Buildr 1.4.5 that may save
> > you some keystrokes,
> >
> > http://buildr.apache.org/more_stuff.html#run
> >
> > alex
> >
>
Re: Java Processes
Posted by Ian Nowland <ia...@gmail.com>.
Do you want me to file an issue, and upload the code I have that produces
this?
--Ian
On Thu, Jul 28, 2011 at 10:16 AM, Alex Boisvert <al...@gmail.com>wrote:
> On Wed, Jul 27, 2011 at 12:29 PM, Ian Nowland <ia...@gmail.com>
> wrote:
>
> > I've got a buildr/jetty/jersey setup I've been playing around with (that
> > took an annoyingly long time to get configured) which is working pretty
> > much
> > as I would like iht to, except for that the process seems to kick off on
> > it's
> > own, meaning I can't see console output and I have to kill -9 it whenever
> I
> > want it to stop. I'm setting it off with a pretty typical:
> >
>
> Hmmm. I can't reproduce this with a simple Java main program. Output goes
> to stdout (as expected) and Ctrl-C kills both the buildr and the java main
> processes.
>
> task :run => :compile do
> > puts('Starting up with classpath ' + compile.dependencies.to_s + "
> "
> > + [compile.target.to_s].to_s)
> > Java::Commands.java('launcher.
> > MyServer', :classpath => compile.dependencies + [compile.target.to_s])
> > end
> >
>
> By the way, there is a standard run task since Buildr 1.4.5 that may save
> you some keystrokes,
>
> http://buildr.apache.org/more_stuff.html#run
>
> alex
>
Re: Java Processes
Posted by Ian Nowland <ia...@gmail.com>.
Yeah, I tried the run task, and the same thing was happening.
I would think that jetty is forking the task, but the println is in the
main, not the jetty server.
--Ian
On Thu, Jul 28, 2011 at 10:16 AM, Alex Boisvert <al...@gmail.com>wrote:
> On Wed, Jul 27, 2011 at 12:29 PM, Ian Nowland <ia...@gmail.com>
> wrote:
>
> > I've got a buildr/jetty/jersey setup I've been playing around with (that
> > took an annoyingly long time to get configured) which is working pretty
> > much
> > as I would like iht to, except for that the process seems to kick off on
> > it's
> > own, meaning I can't see console output and I have to kill -9 it whenever
> I
> > want it to stop. I'm setting it off with a pretty typical:
> >
>
> Hmmm. I can't reproduce this with a simple Java main program. Output goes
> to stdout (as expected) and Ctrl-C kills both the buildr and the java main
> processes.
>
> task :run => :compile do
> > puts('Starting up with classpath ' + compile.dependencies.to_s + "
> "
> > + [compile.target.to_s].to_s)
> > Java::Commands.java('launcher.
> > MyServer', :classpath => compile.dependencies + [compile.target.to_s])
> > end
> >
>
> By the way, there is a standard run task since Buildr 1.4.5 that may save
> you some keystrokes,
>
> http://buildr.apache.org/more_stuff.html#run
>
> alex
>
Re: Java Processes
Posted by Alex Boisvert <al...@gmail.com>.
On Wed, Jul 27, 2011 at 12:29 PM, Ian Nowland <ia...@gmail.com> wrote:
> I've got a buildr/jetty/jersey setup I've been playing around with (that
> took an annoyingly long time to get configured) which is working pretty
> much
> as I would like iht to, except for that the process seems to kick off on
> it's
> own, meaning I can't see console output and I have to kill -9 it whenever I
> want it to stop. I'm setting it off with a pretty typical:
>
Hmmm. I can't reproduce this with a simple Java main program. Output goes
to stdout (as expected) and Ctrl-C kills both the buildr and the java main
processes.
task :run => :compile do
> puts('Starting up with classpath ' + compile.dependencies.to_s + " "
> + [compile.target.to_s].to_s)
> Java::Commands.java('launcher.
> MyServer', :classpath => compile.dependencies + [compile.target.to_s])
> end
>
By the way, there is a standard run task since Buildr 1.4.5 that may save
you some keystrokes,
http://buildr.apache.org/more_stuff.html#run
alex
Re: Java Processes
Posted by Ed Smiley <es...@ebrary.com>.
Haven't been too active on the list lately. Buildr has been behaving itself
very well.
I have an advanced question.
This may have been covered, it seems obvious, but I haven't really seen this
one discussed.
I want to be able to have the option of running Buildr from within a Ruby
application, Chef recipe etc.
And yes, obviously I can exec it off as another process, but that seems
really lame since Buildr is in Ruby.
Hacking around a bit, I came up with the following, which fails on run
test.rb
====
require 'rubygems'
require 'buildr'
include Buildr
include Rake
include RakeFileUtils
app = Application.new
p app # yep object is there...
app.run #blows up
I have already created a buildfile in the same directory.
The error looks like this:
$ ruby test.rb
#<Buildr::Application:0x1015bee40 @on_completion=[], @tty_output=true,
@tasks={}, @default_loader=#<Rake::DefaultLoader:0x1015bec38>,
@rakefile=nil, @settings=#<Buildr::Settings:0x1015be8f0
@application=#<Buildr::Application:0x1015bee40 ...>>,
@loaders={".rake"=>#<Rake::DefaultLoader:0x1015bea30>,
".rf"=>#<Rake::DefaultLoader:0x1015bead0>,
".rb"=>#<Rake::DefaultLoader:0x1015beb70>}, @rakefiles=["buildfile",
"Buildfile", "buildfile.rb", "Buildfile.rb", "rakefile", "Rakefile",
"rakefile.rb", "Rakefile.rb"], @name="rake", @last_description=nil,
@home_dir="/Users/esmiley/.buildr", @top_level_tasks=[], @imported=[],
@on_failure=[], @rules=[], @original_dir="/Users/esmiley/testb", @scope=[],
@pending_imports=[]>
Buildr aborted!
TypeError : can't convert nil into String
/Library/Ruby/Gems/1.8/gems/buildr-1.4.3/lib/buildr/core/application.rb:171:in
`buildfile'
/Library/Ruby/Gems/1.8/gems/buildr-1.4.3/lib/buildr/core/application.rb:217:in
`load_buildfile'
/Library/Ruby/Gems/1.8/gems/buildr-1.4.3/lib/buildr/core/application.rb:213:in
`load_buildfile'
Re: Java Processes
Posted by Antoine Toulme <an...@lunar-ocean.com>.
I would need to investigate the code a bit to find where the java command
forks. Probably annoying enough that we should file a bug for this...
For the second part:
https://github.com/intalio/wapama/blob/master/Buildfile
https://github.com/atoulme/logBot/blob/master/Buildfile
Both examples show complex zips of distribs created based on package(:zip).
Antoine
On Wed, Jul 27, 2011 at 19:29, Ian Nowland <ia...@gmail.com> wrote:
> I've got a buildr/jetty/jersey setup I've been playing around with (that
> took an annoyingly long time to get configured) which is working pretty
> much
> as I would like it to, except for that the process seems to kick off on
> it's
> own, meaning I can't see console output and I have to kill -9 it whenever I
> want it to stop. I'm setting it off with a pretty typical:
>
> task :run => :compile do
> puts('Starting up with classpath ' + compile.dependencies.to_s + " "
> + [compile.target.to_s].to_s)
> Java::Commands.java('launcher.
> MyServer', :classpath => compile.dependencies + [compile.target.to_s])
> end
>
> And then in launcer.MyServer.scala
>
> object MyServer {
>
> def main(args: Array[String]) {
>
>
> System.out.println("Starting up server")
>
> val server = new Server(8080)
> val connector = new SelectChannelConnector()
> server.addConnector(connector)
>
> val holder:ServletHolder = new ServletHolder(classOf[ServletContainer])
>
>
> holder.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
>
> "com.sun.jersey.api.core.PackagesResourceConfig")
> holder.setInitParameter("com.sun.jersey.config.property.packages",
> "com.sample")
> val context = new ServletContextHandler(server, "/",
> ServletContextHandler.SESSIONS)
> context.addServlet(holder, "/*")
> server.start
> server.join
> }
> }
>
>
> When I 'buildr run', while things seem to start up fine, I never see the
> "Starting up server" line. When I kill the buildr:run with a ctrl-c, as I
> mentioned before, the server stays alive.
>
> What's a more manageable way to launch the process?
>
> For bonus points, the documentation is a little sparse on suggestions for
> how to package my code into something a bit more publishable/distributable
> (which I realize is really a general problem that applies to all build
> tools...still, it'd be nice). Are there any suggestions for how to tie a
> bow
> around this system, or is the best thing to do really just to jar it up,
> with a script that does a java -jar?
>
> Thanks,
>
> Ian
>