From e2db7a1ad9d7ca9e1e4d16feb77b0aeb40134703 Mon Sep 17 00:00:00 2001 From: "kestes%walrus.com" Date: Thu, 18 Oct 2001 15:05:57 +0000 Subject: [PATCH] Add support for /var/run/ directory. git-svn-id: svn://10.0.0.236/trunk@105706 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webtools/tinderbox2/src/bin/tinder.cgi | 19 +++++++++++++++--- .../src/clientbin/build_shellscript | 20 +++++++++++++++++-- .../src/default_conf/TinderConfig.pm | 10 ++++++++-- mozilla/webtools/tinderbox2/src/lib/Utils.pm | 14 +++++++++++-- 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/mozilla/webtools/tinderbox2/src/bin/tinder.cgi b/mozilla/webtools/tinderbox2/src/bin/tinder.cgi index 676e858612c..1baa192c3b3 100755 --- a/mozilla/webtools/tinderbox2/src/bin/tinder.cgi +++ b/mozilla/webtools/tinderbox2/src/bin/tinder.cgi @@ -2,8 +2,8 @@ # -*- Mode: perl; indent-tabs-mode: nil -*- # -# $Revision: 1.16 $ -# $Date: 2001-10-10 15:06:48 $ +# $Revision: 1.17 $ +# $Date: 2001-10-18 15:05:57 $ # $Author: kestes%walrus.com $ # $Source: /home/befator/cvs/jail/cvsroot/mozilla/webtools/tinderbox2/src/bin/tinder.cgi,v $ # $Name: not supported by cvs2svn $ @@ -444,7 +444,20 @@ sub daemon_main { symlink ($UID, $FileStructure::LOCK_FILE) || return ; - + + # This file makes writing /etc/rc.d/inid.d scripts easier and its + # naming and location are OS specific. + + # Why have two separate files? (both lock and pid could be combined) + # It is convienient for debugging to move the lock file into the + # HTML tree along with the DB files so that the state gets cleaned + # if I wipe the HTML dir. Howver the init scripts always look for + # the pid file in the same place and I find these scripts + # convienient for stopping programs even when debugging. + + my $pid="$$\n"; + overwrite_file($PID_FILE, $pid); + my ($summary_data); my (@trees) = TreeData::get_all_trees(); diff --git a/mozilla/webtools/tinderbox2/src/clientbin/build_shellscript b/mozilla/webtools/tinderbox2/src/clientbin/build_shellscript index efff68389e4..e443a8dff35 100755 --- a/mozilla/webtools/tinderbox2/src/clientbin/build_shellscript +++ b/mozilla/webtools/tinderbox2/src/clientbin/build_shellscript @@ -32,8 +32,8 @@ # complete rewrite by Ken Estes, Mail.com (kestes@staff.mail.com). # Contributor(s): -# $Revision: 1.9 $ -# $Date: 2001-09-06 18:15:53 $ +# $Revision: 1.10 $ +# $Date: 2001-10-18 15:05:53 $ # $Author: kestes%walrus.com $ # $Name: not supported by cvs2svn $ @@ -294,6 +294,9 @@ sub fatal_error { print LOG "[$LOCALTIME] $_"; } print LOG "\n"; + + unlink ($PID_FILE); + die("\n"); } @@ -331,6 +334,19 @@ sub daemonize { setsid; umask 0; + # Do I want to stop multiple instances from running? I am not + # sure how to deal with multiple instances. + + if ($PID_FILE) { + die("Pid file: $PID_FILE already exists.\n"); + } + + # This file makes writing /etc/rc.d/inid.d scripts easier and its + # naming and location are OS specific. + + my $pid="$$\n"; + overwrite_file($PID_FILE, $pid); + print "$PROGRAM pid: $$\n"; return ; diff --git a/mozilla/webtools/tinderbox2/src/default_conf/TinderConfig.pm b/mozilla/webtools/tinderbox2/src/default_conf/TinderConfig.pm index 673544cc979..7e1bbbb9a2a 100644 --- a/mozilla/webtools/tinderbox2/src/default_conf/TinderConfig.pm +++ b/mozilla/webtools/tinderbox2/src/default_conf/TinderConfig.pm @@ -5,8 +5,8 @@ # customizable settings. -# $Revision: 1.13 $ -# $Date: 2001-10-10 15:09:06 $ +# $Revision: 1.14 $ +# $Date: 2001-10-18 15:05:51 $ # $Author: kestes%walrus.com $ # $Source: /home/befator/cvs/jail/cvsroot/mozilla/webtools/tinderbox2/src/default_conf/TinderConfig.pm,v $ # $Name: not supported by cvs2svn $ @@ -103,6 +103,12 @@ $ERROR_LOG = "/var/log/tinderbox2/tinderbox2.log"; # Where the daemon mode lock (for all trees) is placed $LOCK_FILE = $TINDERBOX_HTML_DIR."/tinderd.lock"; +# Where to place file containing pid, this file makes writing +# /etc/rc.d/inid.d scripts easier and its naming and location are OS +# specific. + +$PID_DIR = "/var/run/"; + # The time between auto refreshes for all pages in seconds. $REFRESH_TIME = (60 * 15); diff --git a/mozilla/webtools/tinderbox2/src/lib/Utils.pm b/mozilla/webtools/tinderbox2/src/lib/Utils.pm index 3555b9940b5..195e6bca4ca 100755 --- a/mozilla/webtools/tinderbox2/src/lib/Utils.pm +++ b/mozilla/webtools/tinderbox2/src/lib/Utils.pm @@ -3,8 +3,8 @@ # Utils.pm - General purpose utility functions. Every project needs a # kludge bucket for common access. -# $Revision: 1.23 $ -# $Date: 2001-10-10 15:08:24 $ +# $Revision: 1.24 $ +# $Date: 2001-10-18 15:05:48 $ # $Author: kestes%walrus.com $ # $Source: /home/befator/cvs/jail/cvsroot/mozilla/webtools/tinderbox2/src/lib/Utils.pm,v $ # $Name: not supported by cvs2svn $ @@ -121,6 +121,15 @@ sub set_static_vars { $LOCK_FILE = ( $TinderConfig::LOCK_FILE || "/usr/apache/cgibin/webtools/tinderbox/tinderd.lock"); + # Where to place file containing pid, this file makes writing + # /etc/rc.d/inid.d scripts easier and its naming and location are OS + # specific. + + $PID_DIR = ( $TinderConfig::PID_DIR || + "/var/run/"); + + $PID_FILE= "$PID_DIR/$PROGRAM.pid"; + # the time between auto refreshes for all pages in seconds. $REFRESH_TIME = ( $TinderConfig::REFRESH_TIME || @@ -398,6 +407,7 @@ sub fatal_error { # we have trouble removing the file we we will be exiting anyway. unlink ($LOCK_FILE); + unlink ($PID_FILE); print "Content-type: text/html\n\n";