|
From: <da...@ix...> - 2003-05-30 18:03:43
|
I'd like to discuss doing away with the Linux specific script in favor of
the generic Unix one.
I believe that all versions of ps available on Linux support the -p option
that the generic script uses. At least, I suspect that all versions since
RedHat 6.3 (since Sun builds java on RH 6.3, I believe that this is a
suitable base to use).
The only problem is that ps often end up in different locations on
different Linux boxes. For instnace, on my box at home, there is a
/usr/bin/ps, but on the machines at work, it is only in /bin.
I have been using the following patch to the generic wrapper for several
weeks now on a variety of Linux boxes. It essentially replaces the
hardcoded references of /usr/bin/ps with $PSEXE, which is detected similar
to how PIDOF is detected in the Linux script. If nothing else, it should
enhance the generic script a little, even if you don't drop the Linux
specific version.
Comments?
mrc
--- wrapper/3.0.3/linux/src/bin/sh.script.in Wed May 28 11:24:07 2003
+++ NodeWarrior/bin/nw Wed May 28 11:23:55 2003
@@ -60,10 +60,21 @@
cd `dirname $REALPATH`
# Process ID
-PIDDIR="/var/run"
+PIDDIR="../logs"
PIDFILE="$PIDDIR/$APP_NAME.pid"
pid=""
+PSEXE="/usr/bin/ps"
+if [ ! -x $PSEXE ]
+then
+ PSEXE="/bin/ps"
+ if [ ! -x $PSEXE ]
+ then
+ echo "Cannot find 'ps'."
+ exit 1
+ fi
+ fi
+
getpid() {
if [ -f $PIDFILE ]
then
@@ -73,7 +84,7 @@
if [ "X$pid" != "X" ]
then
# Verify that a process with this pid is still running.
- pid=`/usr/bin/ps -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
+ pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
if [ "X$pid" = "X" ]
then
# This is a stale pid file.
@@ -131,7 +142,7 @@
kill $pid
sleep 6
- pid=`/usr/bin/ps -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
+ pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
if [ "X$pid" != "X" ]
then
@@ -139,7 +150,7 @@
kill -9 $pid
rm -f $PIDFILE
- pid=`/usr/bin/ps -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
+ pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
fi
if [ "X$pid" != "X" ]
--
Mike Castle da...@ix... www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
|