dbprocs, at least in our environment, has two flaws: o "dbprocs stop" tends to leave one or two processes still running. o Because dbprocs is monolithic, it's hard to tell what those processes are. In order to correct these flaws, Alexis rewrote dbprocs as four small programs. I like his rewrite a lot and I'd like you to consider it as a replacement for the existing dbprocs. This suite should exactly replicate the behavior of the original, with two small exceptions: o When dbp_logrm exits due to $DB_HOME not being set, it now emits an error message and exits with a non-zero status. o dbp_logrm now checks to see if it's already running, as the other two already did. Comments? -- Ben Rosengart (212) 741-4400 x215 1. A robot may not injure entertainment industry profits, or, through inaction, allow entertainment industry profits to come to harm. --Matt McLeod -- Attached file included as plaintext by Ecartis -- #! /bin/sh . /news/lib/innshellvars # dbp_chkpt_watch # Start the checkpointer, write its PID to a lockfile, and remove it # once the checkpointer exits if [ -z "$DB_HOME" ]; then exit fi cd $PATHTMP if [ -f $PATHRUN/db_checkpoint.pid ] ; then if kill -0 `cat $PATHRUN/db_checkpoint.pid` ; then echo "$0 (dbprocs): db_checkpoint already running, not started." else echo "Warning: stale db_checkpoint lock detected (and ignored)." fi fi db_checkpoint -p 1 -k 2000 & echo $! > $PATHRUN/db_checkpoint.pid wait rm -f $PATHRUN/db_checkpoint.pid -- Attached file included as plaintext by Ecartis -- #! /bin/sh . /news/lib/innshellvars # dbp_deadlk_watch # start the deadlock detector, write its PID to a lockfile, and remove it # once the detector exits if [ -z "$DB_HOME" ]; then exit fi cd $PATHTMP if [ -f $PATHRUN/db_deadlock.pid ] ; then if kill -0 `cat $PATHRUN/db_deadlock.pid` ; then echo "$0 (dbprocs): db_deadlock already running, not started." else echo "Warning: stale db_deadlock lock detected (and ignored)." fi fi db_deadlock -t 30 & echo $! > $PATHRUN/db_deadlock.pid wait rm -f $PATHRUN/db_deadlock.pid -- Attached file included as plaintext by Ecartis -- #! /bin/sh . /news/lib/innshellvars # # dbp_rmlogs # Remove db logs that are no longer needed if [ -z "$DB_HOME" ]; then echo "\$DB_HOME is not set, exiting." exit 1 fi cd $PATHTMP if [ -f $PATHRUN/logremover.pid ] ; then if kill -0 `cat $PATHRUN/logremover.pid` ; then echo "$0 (dbprocs): logremover already running, not started." else echo "Warning: stale logremover lock detected (and ignored)." fi fi ( trap "rm -f $PATHTMP/dba.$$ $PATHRUN/logremover.pid ; exit" 1 2 3 15 while [ 1 ]; do sleep 120 db_archive -a >$PATHTMP/dba.$$ if [ -s $PATHTMP/dba.$$ ]; then xargs rm <$PATHTMP/dba.$$ fi done ) & echo $! > $PATHRUN/logremover.pid -- Attached file included as plaintext by Ecartis -- #! /bin/sh . /news/lib/innshellvars # # dbprocs # start or stop processes that support the BerkeleyDB ovdb environment # if [ -z "$DB_HOME" ]; then exit fi cd $PATHTMP case "$1" in stop) if [ -f $PATHRUN/db_deadlock.pid ]; then kill `cat $PATHRUN/db_deadlock.pid` fi if [ -f $PATHRUN/logremover.pid ]; then kill `cat $PATHRUN/logremover.pid` fi if [ -f $PATHRUN/db_checkpoint.pid ]; then kill `cat $PATHRUN/db_checkpoint.pid` sleep 1 # db_checkpoint may not exit right away if it is in the # middle of a checkpoint. So we wait for it here. i=12 while [ $i -gt 0 ]; do [ -f $PATHRUN/db_checkpoint.pid ] || break sleep 5 i=`expr $i - 1` done # run one more checkpoint just to make sure, but not if # the old one is still running [ -f $PATHRUN/db_checkpoint.pid ] || db_checkpoint -1 fi ;; start) # Run checkpointer and deadlock detector ( exec dbp_chkpt_watch ) & ( exec dbp_deadlk_watch ) & # Remove logs that are no longer needed exec dbp_rmlogs ;; *) echo "Usage: $0 " ;; esac