|
From: <Jay...@sc...> - 2008-06-27 12:30:23
|
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
|