Date: Wed, 06 Jan 2010 08:57:56 +0200 From: Yevgen Krapiva <ykrapiva@gmail.com> To: Doug Barton <dougb@FreeBSD.org> Cc: freebsd-rc@freebsd.org Subject: Re: Need help with shutdowning a java process Message-ID: <1262761076.3830.21.camel@kv-po-ykrapivanb.umc.com.ua> In-Reply-To: <4B437D3D.6070209@FreeBSD.org> References: <1262677911.2694.11.camel@kv-po-ykrapivanb.umc.com.ua> <4B437D3D.6070209@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks, I've already read the article but still missing some things. So, I've followed your advice: Now rc script looks like: pidfile="/var/run/${name}.pid" command="/usr/sbin/daemon" command_args="-p ${pidfile} $runcmd" command_interpreter="/usr/local/diablo-jdk1.6.0/bin/java" #flags="-p ${pidfile} $runcmd" Testing script: root@etc/rc.d #./openjsip-location-service onestart ./openjsip-location-service: WARNING: no shebang line in /usr/sbin/daemon Starting openjsip_location_service. 2010-01-06 06:34:13,813 INFO - Location Service started... root@etc/rc.d #./openjsip-location-service onestatus ./openjsip-location-service: WARNING: no shebang line in /usr/sbin/daemon openjsip_location_service is not running. root@etc/rc.d #ps wwaux | grep openjsip root 19814 0.0 0.7 894148 22688 ?? Is 8:34AM 0:00.48 /usr/local/diablo-jdk1.6.0/bin/java -cp :/usr/local/share/openjsip/lib/jain-sdp-1.0.115.jar:/usr/local/share/openjsip/lib/jain-sip-api-1.2.jar:/usr/local/share/openjsip/lib/jain-sip-ri-1.2.115.jar:/usr/local/share/openjsip/lib/jain-sip-sdp-1.2.115.jar:/usr/local/share/openjsip/lib/log4j-1.2.15.jar:/usr/local/share/openjsip/lib/openjsip-0.0.5.jar:/usr/local/share/openjsip/lib/openjsip-remote-0.0.5.jar:/usr/local/share/openjsip/lib/snmp.jar -Djava.security.policy=conf/policy.all -Djava.rmi.server.codebase=file:///usr/local/share/openjsip/lib/openjsip-remote-0.0.5.jar file:///usr/local/share/openjsip/lib/jain-sip-api-1.2.jar openjsip.locationservice.LocationService conf/location-service.properties What means "no shebang line" ? Ok, when I comment command_interpreter line, no warnings are issued. But checking status is also not working. Running sh -x openjsip-location-service showed that: + _pidfile=/var/run/openjsip_location_service.pid + _procname=/usr/sbin/daemon + _interpreter='' So, procname is incorrect. No daemon in processes, there is java only. So, I'm trying to set correct process name: # Subvert the check_pidfile procname check. if [ -f $pidfile ]; then read rc_pid junk < $pidfile if [ ! -z "$rc_pid" ]; then procname=`ps -o command= $rc_pid` echo rc_pid=$rc_pid echo procname=$procname fi fi Testing: root@etc/rc.d #./openjsip-location-service onestatus rc_pid=24821 procname=/usr/local/diablo-jdk1.6.0/bin/java -cp :/usr/local/share/openjsip/lib/jain-sdp-1.0.115.jar:/usr/local/share/openjsip/lib/jain-sip-api-1.2.jar:/usr/local/share/openjsip/lib/jai ./openjsip-location-service: WARNING: no shebang line in /usr/local/diablo-jdk1.6.0/bin/java openjsip_location_service is not running. Running with sh -x showed that: + _pidfile=/var/run/openjsip_location_service.pid + _procname=/usr/local/diablo-jdk1.6.0/bin/java + _interpreter=-cp May be I should simply override stop_cmd and kill process manually using PID only ? On Tue, 2010-01-05 at 09:56 -0800, Doug Barton wrote: > To start with, you should really read the article at > http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html, > I think it would help you get a picture of how some of this should > look. Some more comments below. > > Yevgen Krapiva wrote: > > Hi all, > > > > I have the following rc script: > > > > .. > > name="openjsip_location_service" > > .. > > # Execution command > > runcmd="java -cp $CLASSPATH -Djava.security.policy=conf/policy.all > > -Djava.rmi.server.codebase=\"file://$OPENJSIP_REMOTE_LIB > > file://$JAIN_SIP_API_LIB\" openjsip.locationservice.LocationService > > conf/location-service.properties" > > > > pidfile="/var/run/${name}.pid" > > command="/usr/sbin/daemon" > > > flags="-p ${pidfile} $runcmd" > > Rather than having 2 different variables, you should combine your > "flags" and "runcmd" variables into command_args, which is the usual > way to accomplish what you seem to be trying to accomplish. > > > # When I run java from /usr/local/bin I run javavm indeed (convenient > > wrapper for switching Java VMs). > > # So I need to get the correct processname from output of 'ps' command > > > > # Subvert the check_pidfile procname check. > > Yeah, let's not subvert stuff. :) I'm not really familiar with java, > but what I think you need to do is to set > "command_interpreter=/usr/local/diablo-jdk1.6.0/bin/java" which should > give rc.subr the information it needs to find your process. If that > doesn't work, do 'ps -auxww | grep openjsip' and show us the results. > > > Doug >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1262761076.3830.21.camel>