anchor.diff:  done
   
   # Create the JSVC command line.
  -CMD="$EXEC -home <%=@java_home%> -cp $CP -user $USER -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $LOG_PID -Dcom.webtrends.log.dir=<%=@log_dir%> $JMX_OPTS"
  +CMD="$JAVA_HOME/bin/java -cp $CP -Dcom.webtrends.log.dir=<%=@log_dir%> $JMX_OPTS"
  +
  +# Find current PID if any.
  +FOUND_PID=`ps -ef |grep $MAIN |grep -v grep |awk {print $2}'`
   
   # Check what the caller wants.
   case "$1" in
       start)
  -        if [ ! -f "$LOG_PID" ]; then
  -            cd $HOME_DIR
  +        if [ "" = "$FOUND_PID" ]; then
  +            cd   $HOME_DIR
               echo $CMD $MAIN
  -            `$CMD $MAIN`
  +            exec $CMD $MAIN >$LOG_OUT 2>$LOG_ERR &
           else 
  -            echo "Service already running! File $LOG_PID exists!"
  +            echo "Service already running!"
  +            exit 1
           fi
           ;;
       stop)
  -        if [ -f "$LOG_PID" ]; then
  -            cd $HOME_DIR
  -            `$CMD -stop $MAIN`
  +        if [ "" = "$FOUND_PID" ]; then
  +            echo "Service not running? File $LOG_PID not exist."
  +            exit 1
           else
  -            echo "Service not running? File $LOG_PID not exist."
  +            kill $FOUND_PID
  +            sleep 2
  +            FOUND_PID=`ps -ef |grep $MAIN |grep -v grep |awk {print $2}'`
  +            if [ "" != "$FOUND_PID" ]; then
  +                echo "Sending kill -9 to process."
  +                kill -9 $FOUND_PID
  +            fi
           fi 
           ;;
       status)
           # Status is found via actual running processes, rather than
           # trusting the PID log file.
  -        FOUND=`ps -ef |grep $MAIN |grep -v grep`
  -        if [ "" = "$FOUND" ]; then
  +        if [ "" = "$FOUND_PID" ]; then
               echo "Not running"
               exit 1
           else
  
positive.code: #!/bin/sh
  
  # Setup basic path information.
  EXEC=/usr/bin/jsvc 
  MAIN=com.webtrends.streaming.CollectionDaemon
  USER="<%= @user %>"
  LOG_PID="<%=File.join(@log_dir,"streamingcollection.pid")%>"
  LOG_OUT="<%=File.join(@log_dir,"streamingcollection.out")%>"
  LOG_ERR="<%=File.join(@log_dir,"streamingcollection.err")%>"
  HOME_DIR="<%=@install_dir%>"
  
  # Setup classpath, initially empty.
  CP=""
  
negative.code:             exit 0
          fi
          ;;
      *)
          echo "usage: daemon {start|stop|status}" >&2
          exit 1
          ;;
  esac