You're right...I forgot the shutdown hook....Here 'tis with the shutdown hook:
import org.ops4j.pax.runner.platform.internal.Pipe; public class BrowserStarter { static Pipe err; static Pipe out; static Pipe in; public static final void main(String[] args) throws Exception { try { Process p = Runtime.getRuntime().exec(args[0]); p.waitFor(); err = new Pipe( p.getErrorStream(), System.err ).start( "error" ); out = new Pipe( p.getInputStream(), System.out ).start( "out" ); in = new Pipe( p.getOutputStream(), System.in ).start( "in" ); destroyFrameworkOnExit(p, new Pipe[] {err,out,in}); } finally { if(err != null) err.stop(); if(out != null) out.stop(); if(in != null) in.stop(); } } private static void destroyFrameworkOnExit( final Process process, final Pipe[] pipes ) { Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() { public void run() { try { for ( Pipe pipe : pipes ) { pipe.stop(); } } finally { process.destroy(); } } } ) ); } } I had high hopes that this would be it. But when I started the service, it spiked (a little higher this time at 63%), then back down to 0%. So...I suppose that I should try profiling it. Great suggestion. I'll give it a shot and report back what I find. Alin Dreghiciu wrote: > Looks like the only thing is not there now is the shutdown hook. which > is a simple thread that stops the pipes and destroys the started > process. > But, can't we figure out what is the tread that is consuming the CPU > using a java profiler? We have an open source license for JProfiler. > > On Thu, Jul 31, 2008 at 3:27 PM, Craig Walls <[EMAIL PROTECTED]> wrote: > >> So far, no good. Here's what BrowserStarter.java looks like now: >> >> import org.ops4j.pax.runner.platform.internal.Pipe; >> >> public class BrowserStarter { >> static Pipe err; >> static Pipe out; >> static Pipe in; >> >> >> public static final void main(String[] args) throws Exception { >> try { >> Process p = Runtime.getRuntime().exec(args[0]); >> p.waitFor(); >> >> err = new Pipe( p.getErrorStream(), System.err ).start( "error" ); >> out = new Pipe( p.getInputStream(), System.out ).start( "out" ); >> in = new Pipe( p.getOutputStream(), System.in ).start( "in" ); >> } finally { >> if(err != null) err.stop(); >> if(out != null) out.stop(); >> if(in != null) in.stop(); >> } >> } >> } >> >> And my jsl.ini's cmdline looks like this: >> >> cmdline = -cp c:/semantra/bin;c:/semantra/bin/pax/pax-runner-0.12.0.jar >> BrowserStarter "java -jar >> c:/semantra/bin/org.eclipse.osgi_3.4.0.v20080605-1900.jar -console 8888" >> >> As before, when I start the service, there's a small spike (about 40% or >> so), then it settles back down to 0%. Of course, that's a good thing, >> except that it does nothing to explain why Pax Runner starts up as a >> service consuming 100% of the CPU. >> >> I'm still tinkering and looking around at Pax Runner source on my end to >> see if I can figure it out. But I wanted to report the status of this >> experiment to see if you guys have any ideas. >> >> >> >> Niclas Hedhman wrote: >> >>> On Thursday 31 July 2008 05:44, Craig Walls wrote: >>> >>> >>>> public class BrowserStarter { >>>> public static final void main(String[] args) throws Exception { >>>> Runtime.getRuntime().exec(args[0]); >>>> } >>>> } >>>> >>>> >>> I am also not on Windows (who uses that anyway? ;-) ) >>> >>> Perhaps change to; >>> >>> public class BrowserStarter { >>> public static final void main(String[] args) throws Exception { >>> Process p = Runtime.getRuntime().exec(args[0]); >>> p.waitFor(); >>> } >>> } >>> >>> And if that doesn't do it, look up the Pipe class in Pax Runner and add that >>> by; >>> >>> static Pipe err; >>> static Pipe out; >>> static Pipe in; >>> >>> err = new Pipe( process.getErrorStream(), System.err ).start( "error" ); >>> out = new Pipe( process.getInputStream(), System.out ).start( "out" ); >>> in = new Pipe( process.getOutputStream(), System.in ).start( "in" ); >>> >>> and the Shutdown hook to cleanup properly. >>> >>> >>> Cheers >>> >>> >> _______________________________________________ >> general mailing list >> general@lists.ops4j.org >> http://lists.ops4j.org/mailman/listinfo/general >> >> > > > > _______________________________________________ general mailing list general@lists.ops4j.org http://lists.ops4j.org/mailman/listinfo/general