|
From: Leif M. <le...@ta...> - 2008-07-12 05:34:06
|
Jay,
Thanks for the log. Looking at it you can see that the Ruby thread is
indeed a "daemon" thread:
"Ruby Thread5832210" daemon prio=6 tid=0x03635400 nid=0x1328 in
Object.wait() [0x0345e000..0x0345fb98]
The only non-daemon thread at the time of the thread dump is:
"Wrapper-Startup-Runner" prio=6 tid=0x02df2000 nid=0x1410 waiting on
condition [0x0303f000..0x0303fd18]
The startup runner is a simple thread that the Wrapper starts to keep
the JVM running as the user application starts up. Once the
WrapperListener.start method returns the above startup runner will
complete. If there are not any other non-daemon threads left
running at that point, the JVM itself will start the shutdown process.
Cheers,
Leif
On Fri, Jul 11, 2008 at 10:05 PM, <Jay...@sc...> wrote:
>
> Hi Leif... still haven't turned ont he time stamps.. (I'll do that next)
>
> But it looks as if ruby threads are daemon threads...
>
> Jay
>
>
> ________________________________
>
> From: wra...@li...
> [mailto:wra...@li...] On Behalf Of "Leif
> Mortenson" <le...@ta...>
> Sent: Friday, June 27, 2008 3:03 PM
> To: wra...@li...
> Subject: Re: [Wrapper-user] Using the wrapper integration method 3
>
>
> Jay,
> I am not sure how Ruby would be doing this but it would surprise beif
> they were daemons by default.
>
> Try doing a thread dump. The JVM looks like it is shutting down
> fairly quickly so try adding code like the following after you start
> your Ruby thread.
>
> try {
> Thread.sleep(500); // Let Ruby start.
> } catch (InterruptedException e) {
> //Something
> }
> org.tanukisoftware.wrapper.WrapperManager.requestThreadDump();
>
> A daemon thread will look something like this:
> "Reference Handler" daemon prio=10 tid=0x0003efb0 nid=0x308 in
> Object.wait() [0x02b8f000..0x02b8fd68]
>
> Non daemon like this:
> "AWT-EventQueue-0" prio=7 tid=0x02d65170 nid=0x940 in Object.wait()
> [0x0436f000..0x0436fd68]
>
> If all else fails, you may need to create a simple java thread which
> starts and loops until a flag is set from the WrapperListener.stop
> method or something.
>
> Cheers,
> Leif
>
> On Fri, Jun 27, 2008 at 9:29 PM, < Jay...@sc...> wrote:
>> Sorry about the no timestamps... How do I turn those on?
>>
>> What am I doing...
>>
>> In my start method I am spinning up a Jruby VM and in that VM I am
> spawning
>> a thread. It is my understanding that in Jruby .. Ruby threads are
> Java
>> threads... But they may not be non daemon threads I will look into
> that.
>>
>> Here are the pertinent functions:
>>
>> public Integer start( String[] args)
>> {
>> if (_service == null)
>> {
>> LauncherOptions opts = new LauncherOptions();
>> CmdLineParser parser = new CmdLineParser(opts);
>> try{
>> parser.parseArgument(args);
>> } catch( CmdLineException e ) {
>> System.err.println(e.getMessage());
>> System.err.println(" Example: java
>> ServiceLauncher"+parser.printExample(ALL));
>> parser.printUsage(System.err);
>> System.err.println();
>> return -1;
>> }
>> initialize(opts.serviceClassName, opts.serviceFileName,
>> opts.serviceInstanceName);
>>
>> }
>>
>> _service.start();
>> return null;
>> }
>>
>> public void initialize(String serviceClassName, String serviceFile,
> String
>> serviceName)
>> {
>> try {
>> String filename = serviceFile.split("\\.")[0];
>> // Create runtime instance of the Ruby VM
>> _rubyRuntime = Ruby.newInstance();
>> _rubyRuntime.evalScriptlet(String.format("require '%s'",filename));
>> Object rfj =
>> _rubyRuntime.evalScriptlet(String.format("%s.new",serviceClassName,
>> serviceName));
>> rfj = org.jruby.javasupport.JavaEmbedUtils.rubyToJava(_rubyRuntime,
>> (org.jruby.runtime.builtin.IRubyObject) rfj,
>> AffinityService.class); //((AffinityService)rfj).start();
>>
>> _service = (AffinityService)rfj;
>>
>> } catch (Throwable e) {
>> System.err.println("Exception creating the service: ");
>> e.printStackTrace(System.err);
>> }
>> }
>>
>> Here is the Ruby code that gets executed:
>>
>> class RubyService < tv.seachange.affininty.util.AffinityService
>> attr_reader :name
>> def initialize
>> #configure the service for the common stuff
>> @name = "RubyService"
>> end
>>
>> def start
>> @thread = Thread.new do
>> @started = true
>> spin_up
>> end
>> end
>>
>> def stop
>> @started = false
>> spin_down
>> end
>> end
>>
>>
>>
>> ________________________________
>>
>> From: wra...@li...
>> [mailto:wra...@li...] On Behalf Of "Leif
>> Mortenson" < le...@ta...>
>> Sent: Thursday, June 26, 2008 10:48 PM
>> To: Wrapper User List
>> Subject: Re: [Wrapper-user] Using the wrapper integration method 3
>>
>>
>> Jay,
>> see this part of the log:
>>
>>> jvm 1 | WrapperManager Debug: calling WrapperListener.start()
>>> jvm 1 | WrapperManager Debug: Waiting for WrapperListener.start
> runner
>>> thread to complete.
>>> jvm 1 | WrapperManager Debug: WrapperListener.start runner thread
> started.
>>> jvm 1 | Starting up!
>>> jvm 1 | WrapperManager Debug: WrapperListener.start runner thread
> stopped.
>>> jvm 1 | hi
>>> jvm 1 | WrapperManager Debug: returned from WrapperListener.start()
>>> jvm 1 | WrapperManager Debug: Send a packet STARTED :
>>> wrapperp | read a packet STARTED :
>>> wrapper | JVM signalled that it was started.
>>> jvm 1 | WrapperManager Debug: Startup runner thread stopped.
>>> jvm 1 | WrapperManager Debug: ShutdownHook started
>>
>> The Wrapper is calling WrapperListener.start in your application.
>> That returns and the WrapperManager reports that the application has
>> started. The WrapperManager starts up something called the start
>> runner which runs while the application is being started to keep the
>> JVM from shutting itself down due to a lack of non-daemon threads.
>> The problem is that as soon as that thread completes, there are no
>> longer any non-daemon threads running so the JVM is initiating a
>> shutdown. This is all correct behavior for the Wrapper.
>>
>> What exactly are you doing inside of your WrapperListener.start
>> method? Are you starting any non-daemon threads which make up the
>> application that should be running?
>>
>> If we exchange any more log files, please include time stamps. They
>> are useful in understanding the timing of when things happen.
>>
>> Cheers,
>> Leif
>>
>> On Fri, Jun 27, 2008 at 7:13 AM, < Jay...@sc...> wrote:
>>> Leif,
>>>
>>> Here is the log. ...
>>>
>>> It could definitely be a thread thing.
>>>
>>> I am spinning up a thread in Jruby. (my java code launches a ruby vm
> and
>>> in
>>> ruby I am creating a thread)
>>>
>>> Jay
>>>
>> < log snip>
>>>
>>>
>>>
>>> ====
>>>
>>> Could you please set the wrapper.debug=true property and then reply
> with
>>> the resulting wrapper.log attached. I only need to see a single
> Wrapper
>>> invocation so delete the old wrapper.log file first. The log should
>>> allow me to say what your exact problem is.
>>>
>>> Cheers,
>>> Leif
>>>
>>> Jay...@sc... wrote:
>>>> Hi,
>>>>
>>>> I'm playing around with the service wrapper and trying to get an
> example
>>>> running using integration method 3. I'm running on the Mac OS X.
>>>>
>>>> Everything appears to work. The service starts up when I use the
> start
>>>> script (sh.script.ln) except that after a few seconds the
> infrastructure
>>>> appears to call a stop on my service.
>>>>
>>>> Does anyone know the reasons why the stop would be called? I've
>>>> returned null from my start method. I spun up my logic in a thread
>>>> although I did the thread start in a wierd way. (what if the thread
>>>> exited (that's not necessarily happening but I'm trying to learn)?).
>>>>
>>>> My service is a very simple loop where I'm just printing a message
> to
>>>> std out every second.
>>>>
>>>
>>
>>
> ------------------------------------------------------------------------
> -
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> Wrapper-user mailing list
>> Wra...@li...
>> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>>
>>
>>
> ------------------------------------------------------------------------
> -
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> Wrapper-user mailing list
>> Wra...@li...
>> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>>
>>
>
> ------------------------------------------------------------------------
> -
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Wrapper-user mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>
|