From eb07f1f3af53c69f3bacb9f088b669cbfddcc3cc Mon Sep 17 00:00:00 2001 From: Christian Fowler Date: Thu, 29 Nov 2007 07:20:57 +0000 Subject: cleanup daemonize so it auto restarts process properly --- daemonize/daemonize.php | 14 ++++++-------- daemonize/is_up.sh | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'daemonize') diff --git a/daemonize/daemonize.php b/daemonize/daemonize.php index 623302b..3711f3b 100644 --- a/daemonize/daemonize.php +++ b/daemonize/daemonize.php @@ -187,17 +187,15 @@ exit(0); # Access functions. function is_alive($pid) { - $result = system( dirname( __FILE__ )."/is_up.sh $pid"); -error_log( $result ); -# to_log("is_alive (${BINDIR}is_up $pid) returned $result"); - return (0 < $result); + $output = array(); + exec( dirname( __FILE__ )."/is_up.sh $pid", $output ); + $result = $output[0]; + to_log("is_alive (".dirname( __FILE__ )."/is_up.sh $pid) returned $result"); + return (0 < $result); } function to_log($string) { - global $DEBUG; - if ($DEBUG) { - error_log(date("r")." - $string\n"); - } + error_log(date("r")." - $string\n"); } function zero_file($pidfile) { diff --git a/daemonize/is_up.sh b/daemonize/is_up.sh index 7a7d1af..f821a78 100755 --- a/daemonize/is_up.sh +++ b/daemonize/is_up.sh @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash # Wrapper script because in safe mode PHP gloms all those together. -ps -ef | grep $1 | grep daemonize | wc -l +ps -ef | grep -v $0 | grep $1 | grep daemonize | wc -l -- cgit v1.3