|
From: Leif M. <le...@ta...> - 2004-01-14 09:17:51
|
Sandeep,
After spending some time looking through the code, I managed to get
this fixed. I have
not personally made use of the ServiceManager's restart functionality in
the past and so
was not aware that I was not handling it correctly.
In 3.0.5, it looks like the Wrapper would exit with the correct exit
code if
WrapperManager.stop was used to stop the JVM. It was not working
correctly when
System.exit was used. That is when run as a Console app.
Running as an NT service was a different issue. A service has two
exit codes, a
win32 exit code and a service specific exit code.
SERVICE_STATUS.dwWin32ExitCode
SERVICE_STATUS.dwServiceSpecificExitCode
I had been setting the dwWin32ExitCode to the exit code of the JVM
correctly but
then I was proceeding to tell the service manager that the service had
stopped.
Apparently the failure recovery features of the service manager are only
invoked if the
service terminates abnormally. If it exits without sending a stopped
message then the
service manager assumes that the service failed even if it exited with a
code of 0.
I have implemented this so that the Wrapper will exit with an exit
code of 0 after
notifying the service manager that it has stopped if there was no
error. In the event
of a non-zero exit code, I exit the service before sending the stopped
message.
This all appears to be working.
Does anyone know what the intended differences between the win32
exit code
and service specific exit codes above are? The MSVC API docs do not really
explain how they are supposed to be used, and I want to make sure that I am
setting them to values that will be useful to users.
Also, the service recovery features allow you to specify a period
after which
any restart of the service will be reset. Setting this to 0 seems to
reset the count
immediately after launching a service. If you have specified a single
restart then the
service will restart infinitely.
If you set it to 1 day, then it will not restart if the service has
been restarted at all
within the last 24 hours. This is true even if the service was manually
stopped
sometime during that time period. Does that sound correct? I don't
think I have
any control over it so I hope so.
If anyone knows any sites that explain how services should be
behaving here
please forward them to me for my reference.
Cheers,
Leif
Sandeep Khanna wrote:
>Hi,
>
>Thanks for the prompt response. After visiting
>http://sourceforge.net/tracker/index.php?func=detail&aid=852491&group_id=39428&atid=425190
>
>I tried using WrapperManager.stop(-1) directly. On the console it showed
>that the JVM and eventually the wrapper exited with -1. But, when I run
>the same as a Windows service, the service just starts and stops
>normally without compaining about anything!
>
>Is there a specific exit code/codes for the Windows service manager to
>identify a service failure? A quick search on google did not reveal
>anything also.
>
>I appreciate your other suggestion about a seperated class and sending
>recovery mail using Java mail. Unfortunately, we wouldn't be going that way.
>
>Thanks in advance,
>Sandeep Khanna
>
>----- Original Message -----
>From: Leif Mortenson <le...@ta...>
>Date: Thursday, January 8, 2004 7:53 pm
>Subject: Re: [Wrapper-user] Java service - windows service recovery?
>
>
>
>>Sandeep,
>> Sorry, but the Wrapper does not currently exit with the correct
>>exit
>>code. I added
>>a feature request for this last month and try to get it into the
>>Wrapper
>>for a near future
>>version. You might want to monitor the feature request so you will
>>get
>>notifications
>>on its progress.
>>
>>
>>
>http://sourceforge.net/tracker/index.php?func=detail&aid=852491&group_id=39428&atid=425190
>
>
>> One alternative for you would be to write a simple utility
>>class
>>which you specify
>>as the main class (Ie the first parameter to WrapperSimpleApp) It
>>would start by
>>calling the WrapperManager.getJVMId() method to find out which
>>invocation number
>>the JVM was. If it is < 4 then call you real application's main
>>method. Otherwise
>>call a method that executes SendMail and then calls System.exit().
>>
>>Alternatively you
>>could make use of the Java Mail API rather than using SendMail. It
>>is
>>quite easy to
>>use.
>>
>> I am also working on another feature that will allow you to run
>>arbitrary external
>>programs in response to various events in the Wrapper life cycles.
>>Some
>>users have
>>needed this functionality so they could, for example, run an
>>application
>>after a JVM
>>crashes, but before a new one is launched. I was planning to have
>>events for the
>>startup and shutdown of the Wrapper as well. This feature is
>>still in
>>the design phase
>>so if you have any requirements you would like me to consider, go
>>ahead
>>and post them.
>>
>>
>>
>http://sourceforge.net/tracker/index.php?func=detail&aid=837037&group_id=39428&atid=425190
>
>
>>Cheers,
>>Leif
>>
>>Sandeep Khanna wrote:
>>
>>
>>
>>>Hi All,
>>>
>>>We have been using Java Service Wrapper for the past several
>>>
>>>
>>months to
>>
>>
>>>run a couple of Java programs as Windows services.
>>>
>>>Our current requirement needs us to use the Windows "service recovery
>>>options". In the Properties page of a service one can set 3 different
>>>actions to take when a service fails to start for 3 consecutive
>>>
>>>
>>times.>We needed this to be able to execute a restart the first 2
>>failures and
>>
>>
>>>execute a command-line SendMail.exe to send mail to support on the
>>>
>>>
>>3rd>failure.
>>
>>
>>>Unfortunately, my investigation has revealed that the Java Service
>>>Wrapper does not return an exit code to the Windows Service
>>>
>>>
>>manager to
>>
>>
>>>trigger the service recovery settings. I even tried using the 3
>>>integration technique as mentioned on the website, but to no success!
>>>
>>>Can somebody comment if this is possible using Java Service
>>>
>>>
>>Wrapper and
>>
>>
>>>it's current feature set and/or I am missing something here?
>>>
>>>If YES, please explain how?
>>>If NO, please suggest alternatives?
>>>
>>>Thanks in advance,
>>>Sandeep Khanna
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: Perforce Software.
>Perforce is the Fast Software Configuration Management System offering
>advanced branching capabilities and atomic changes on 50+ platforms.
>Free Eval! http://www.perforce.com/perforce/loadprog.html
>_______________________________________________
>Wrapper-user mailing list
>Wra...@li...
>https://lists.sourceforge.net/lists/listinfo/wrapper-user
>
>
>
|