Menu

#32 Posix: apppid of spawned process is not written

All
closed-fixed
nobody
None
5
2013-12-20
2011-05-21
No

Hi I rely on proper shutdown of the spawned process, but looking at the code I see it getting started with Runtime.exec in PosixService startProcess and no pid gets written to disk. So it cannot be properly stopped (appid is always -1 at my side). I see that the pidfile config is hardcoded. How would be a nice way to fix that ? Ididn't see how it gets stopped right now, but my shutdownhooks are not beeing called and thats a showstopper.

Discussion

  • rzo

    rzo - 2011-05-21

    hello,

    what OS are you running on ? yajsw version ? jvm ?
    note that pid file is created in the init method of PosixService

    i tested it again on ubuntu and the pid file is generated correctly. please note that you have to execute installDaemon and startDaemon has admin, otherwise you have may have the required user rights to access the etc and var/run folders.

    -- Ron

     
  • Anonymous

    Anonymous - 2011-05-21

    I'm running on debian with OpenJDK 6, tried alse sun6, yajsw 10.6. I see the file should be written in postStart(). I tried to configure wrapper.java.pidfile but in /var/run I see only the pid of the wrapper process. There should be two files. However when I launch with -c (pidfile also missing) the spawned process gets terminated (I don't see how, because I'm running in console?) if I start with the script the spawned process gets terminated sometimes (not always) but his shutdownhooks are never executed. That what I see so far. Let me know how I can help.

     
  • Anonymous

    Anonymous - 2011-05-21

    I tried with 10.7:
    s15447269:/opt/mango# /etc/init.d/buchmanager stop
    Stopping buchmanager ...
    May 21, 2011 5:22:02 PM org.apache.commons.vfs.VfsLog info
    INFO: Using "/tmp/vfs_cache" as temporary files store.
    May 21, 2011 5:22:02 PM org.rzo.yajsw.os.posix.PosixService init
    INFO: /etc/init.d/buchmanager already exists
    ************* STOPPING buchmanager ***********************

    May 21, 2011 5:22:03 PM org.rzo.yajsw.os.posix.PosixService getPid
    INFO: wrapper pid file: /var/run/wrapper.buchmanager.pid
    May 21, 2011 5:22:03 PM org.rzo.yajsw.os.posix.PosixService stopProcess
    INFO: stop daemon with pid 3887
    rudi 0
    May 21, 2011 5:22:04 PM org.rzo.yajsw.os.posix.PosixService getAppPid
    INFO: app pid file: /var/run/wrapper.java.buchmanager.pid
    May 21, 2011 5:22:04 PM org.rzo.yajsw.os.posix.PosixService stopProcess
    INFO: stop daemon app with pid -1
    May 21, 2011 5:22:04 PM org.rzo.yajsw.os.posix.PosixService getPid
    INFO: wrapper pid file: /var/run/wrapper.buchmanager.pid
    Service buchmanager stopped

     
  • Anonymous

    Anonymous - 2011-05-21

    I fail to set the loglevel to debug. Is there any trick with that ?

     
  • Anonymous

    Anonymous - 2011-05-23

    Sorry for spamming, but I could need some assistance. I set the loglevel to DEBUG but still only get INFO msgs. And on the other hand I don't get any logfile output even though I enabled it. I'll try to attach my config and really hope that you assist me. I could debug the problem on wednesday.

     
  • Anonymous

    Anonymous - 2011-05-23
     
  • rzo

    rzo - 2011-05-23

    hello,

    you are not spamming, sorry on my side for not being able to respond earlier.

    currently yajsw is set to log only INFO loggings. to get more information you can set in the configuration file:

    wrapper.debug = true

    this will log some more details.

    pls post your configuration, so that i may see what is going on.
    generally a log file is generated. if none is generated, then you may have either some wrong configuration, or no user rights to create the log file at the configured location.

    what OS are you running on ?

    yes, it is correct, that you should have both pid files, but, before we should be able to get it to run as console using runConsole.sh and we should have a log file.

    -- Ron

     
  • rzo

    rzo - 2011-05-23

    ps: sorry, did not see that you have attached the log file.

     
  • rzo

    rzo - 2011-05-23

    concerning the configuration:
    try the following:

    wrapper.working.dir=<absolute path to the working dir>

    wrapper.java.app.jar=monitor.jar

    where is monitor.jar ? in the working dir above ?

    wrapper.java.classpath.1=service/lib/core/groovy/groovy-all-1.7.7.jar

    is this path relative to the working dir ?

    pls set:

    wrapper.console.loglevel=INFO
    wrapper.logfile.loglevel=INFO
    wrapper.logfile.maxsize=10m

    we should first get your process to run correctly, then we could try to change the configration to your needs.

    -- Ron

    -- Ron

     
  • Anonymous

    Anonymous - 2011-05-24

    HI I attached my config as a file. I tried setting wrapper.debug to true but still only info msgs. No log file. I deployed all libs except the groovy folder. maybe I am missing something important?

     
  • rzo

    rzo - 2011-05-24

    hello,

    as stated, all logging is done with the "INFO" level. with wrapper.debug you just get more logging.

    the working directory in your configuration is relative. therefore it assumes that your monitor.jar is in the folder:

    /etc

    and logging will be to

    /etc/log/monitor.log

    which i assume is not the case.

    you should set an absolute path to the the working directory.

    you should keep yajsw within a separate folder and maintain the folder structure of yajsw for all jar files.

    before getting it to run as a daemon you should be able to get it to run using runConsole.sh

    -- Ron

    -- Ron

     
  • Anonymous

    Anonymous - 2011-05-25

    I guess you're on the wrong track with the relative path, as it works fine and does find the correct path to my monitor.jar plus I don't see log in etc. I tried setting an apsolute path with absolutely no difference. I'll attach the output from runConsole, It get's the pid of the process but no pidfile is written.

     
  • Anonymous

    Anonymous - 2011-05-25
     
  • Anonymous

    Anonymous - 2011-05-25

    Today I tried the following: Installed on 32bit Ubuntu 10.4, threw in a fresh unzip of the yasw download into my service folder to make sure I have everything on board. Got the same problem. You can take a look at hudson.eiswind.de to get the latest Server build if you want to try for your own. Take the setup.jar

     
  • Anonymous

    Anonymous - 2011-05-25

    Ok I stripped won to a dummy jar and a plain yasw installation. didn't work until I set wrapper.java.pidfile tp a meaningful value. now I find the pidfile in the wrapper directory and the daemon app gets stopped, but I do not see my shutdown hook beeing called. when I launch with runConsole and press CTRL+C everything is fine. but when i run as daemon and stop with stopDaemon the shutdown hook is not beeing executed. How do you kill the process in daemon mode ?

    PS Still no logfile at all-

     
  • rzo

    rzo - 2011-05-25

    hello,

    concerning the log file:
    could you pls try and set the property wrapper.logfile to point to a full path not to a relative one.

    is the log file which you uploaded from a run with the configuration file which you downloaded ?

    what debian release are you using ?
    i will install it on the weekend and see if i can reproduce your issues.

    -- Ron

     
  • Anonymous

    Anonymous - 2011-05-26

    Hi again, Im on Squeeze 64 bit.
    I get a logfile when I set an absolute path. What I can see there and from the code is that the shutdown is not the same as when I run with console, the processes seem to get killed and halted so that I don't get my shutdown hooks.
    I could live without the logfile if you point my to the right halt statement that I must replace with System.exit() to get my shutdown hook.
    I have seen quite a bunch of them

     
  • rzo

    rzo - 2011-05-26

    hello,

    thanks for taking your time and for the feedback.
    i will check this out and get back to you.

    -- Ron

     
  • rzo

    rzo - 2011-05-29

    hello,

    yes, this is a bug.
    the issue is with the way -Xrs is handled on Linux.
    instead of ignoring the signals the jvm process is killed.
    for this reason the wrapper is killed and it does not send a stop command to the application. the application however, after 15 seconds, senses that the wrapper is gone and is cleanly stopped by calling exit(-1) but nothing is logged since the wrapper has been killed.
    as a workaround remove the "-Xrs" from the generated daemon script.

    -- Ron

     
  • rzo

    rzo - 2011-05-29
    • status: open --> open-accepted
     
  • rzo

    rzo - 2011-06-01

    hello,

    did you have the time to check out the workaround ?
    the change in the code will be available in the next release.

    -- Ron

     
  • Anonymous

    Anonymous - 2011-06-01

    Sorry Ron, no feedback means I didn't have time to check this. I hope I can do so on the weekend.

     
  • Anonymous

    Anonymous - 2011-06-02

    I uncommented the -Xrs in WrappedService and WrappedJavaProcess (was unsure which is responsible) and now it works. Shutdownhook is running Thanks for investing your time into this !

     
  • rzo

    rzo - 2013-12-20
    • status: open-accepted --> closed-fixed
    • Group: --> All
     

Log in to post a comment.