a quick scan of the source gives us some cluesif  PID is not there procrun 
exits with a -1fd = open(args->pidf, O_RDONLY, 0);
    if (!quiet)
        log_debug("get_pidf: %d in %s", fd, args->pidf);
    if (fd < 0) {
        /* something has gone wrong the JVM has stopped */
        return -1;
    } later on with wait_child we check again if PID is not alive in which case 
a 1 is returned  /* check if the pid file process exists */
        fd = open(args->pidf, O_RDONLY);
        if (fd < 0 && havejvm) {
            /* something has gone wrong the JVM has stopped */
            return 1;
        }else{ ...return 0; /* ready JVM started ..0 is returned to internal 
functions*/} /*if procrun returns 0 internally you're JVM is started*/  /*.. 
the chronology for procrun denoument..*/ stop_child() while (count > 0) {
            sleep(1);
            pid = get_pidf(args, true);
            if (pid <= 0) {
                /* JVM has stopped... the pid is non-existent*/
                return 0;
            }
            count--;
        }
        signal(SIGTERM, controller);
        signal(SIGINT, controller);        while (waitpid(pid, &status, 0) != 
pid) {
            /* Waith for process */
        }        /* The child must have exited cleanly */
        if (WIFEXITED(status)) {
            status = WEXITSTATUS(status);            /* Delete the pid file */
            if (args->vers != true && args->chck != true && status != 122)
                unlink(args->pidf);            /* If the child got out with 123 
he wants to be restarted */
            /* See java_abort123 (we use this return code to restart when the 
JVM aborts) */
            if (status == 123) {
                log_debug("Reloading service");
                /* prevent looping */
                if (laststart + 60 > time(NULL)) {
                    log_debug("Waiting 60 s to prevent looping");
                    sleep(60);
                }
                continue;
            }
            /* If the child got out with 0 he is shutting down */
            if (status == 0) {
                log_debug("Service shut down");
                return 0;
            }    remove_tmp_file(args);
    log_debug("Shutdown or reload requested: exiting");    /* Stop the service 
*/
    if (java_stop() != true)
        return 6;  /*cannot stop java*/
    if (doreload == true)
        ret = 123;
    else
        ret = 0;    /* Destroy the service */
    java_destroy();    /* Destroy the Java VM */
    if (JVM_destroy(ret) != true)
        return 7;

 yes if all goes well the JVM should be destroyed
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.

 > From: james.w...@infor.com
> To: user@commons.apache.org
> Subject: RE: Commons daemon - stop the service
> Date: Thu, 7 Jun 2012 18:06:03 +0000
> 
> I have played with procrun a bit more and realized that SCM waits for at most 
> two minutes. After that, it shows a message saying it got no response from 
> the process and displays "stopping" as status on the service. But when the 
> process finally ends, it shows "stopped" status (you have to manually refresh 
> the SCM). 
> Procrun has a parameter "StopTimeout", which "Defines the timeout in seconds 
> that procrun waits for service to exit gracefully."  What happens after the 
> timeout period? Does procrun shut down the JVM?
> Thanks.
> 
> James
> 
> -----Original Message-----
> From: Mladen Turk [mailto:mt...@apache.org] 
> Sent: Thursday, May 31, 2012 2:16 PM
> To: user@commons.apache.org
> Subject: Re: Commons daemon - stop the service
> 
> On 05/31/2012 07:53 PM, James Wang wrote:
> > Thanks for the comments.
> > I set both start mode and stop mode to JVM.
> 
> OK.
> 
> > What will happen when a thread needs 20 more minutes to complete its job?
> 
> Well for something like that procrun is not the toolkit to use.
> First of all, if you need to frequently start/stop service why using the 
> service at the first place?
> The sole purpose of service concept is to start the application at boot mode 
> or on demand and to start them in correct order.
> 
> Then there is absolute limit which OS imposes on the service shutdown 
> timeout, and this is for all services on the system, see 
> http://support.microsoft.com/kb/Q146092
> 
> So the only clean solution is that your shutdown code does the actual cleanup 
> causing the clean exit.
> 
> By spec, JVM won't exit if you have non-daemon threads running, so if you 
> cant make them exit, then the only solution is System.exit, which calls OS 
> process _exit() which causes the SCM to think service failed.
> 
> Also you should design your application differently for service and command 
> line mode.
> 
> Procrun does not need to call the main() method.
> Take a look at Tomcat. We call Bootstrap start/stop methods and main() calls 
> Bootstrap.start (after setting correct mode)
> 
> 
> 
> Regards
> --
> ^TM
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 
                                          

Reply via email to