From a0198dc43526022bd5ab3e768ee4ad518982c5df Mon Sep 17 00:00:00 2001 From: TheTroll Date: Fri, 2 Apr 2010 15:59:49 +0200 Subject: Improved status reporting --- bin/session.php | 61 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 22 deletions(-) (limited to 'bin/session.php') diff --git a/bin/session.php b/bin/session.php index e52b6e4..e854058 100644 --- a/bin/session.php +++ b/bin/session.php @@ -197,11 +197,11 @@ function sessiondeletesingle($session) $cmd = ""; // First kill ffmpeg - if (file_exists($ram ."ffmpeg.pid")) + if (is_pid_running($ram ."ffmpeg.pid")) $cmd .= " kill `cat " .$ram ."ffmpeg.pid`; rm " .$ram ."ffmpeg.pid; "; // Then kill segmenter - if (file_exists($ram ."segmenter.pid")) + if (is_pid_running($ram ."segmenter.pid")) $cmd .= " kill `cat " .$ram ."segmenter.pid`; rm " .$ram ."segmenter.pid; "; addlog("Sending session kill command: " .$cmd); @@ -236,10 +236,10 @@ function getstreamingstatus($session) if (count(glob($path . '/*.ts')) < 2) { - if (!file_exists($path .'/segmenter.pid')) + if (!is_pid_running($path .'/ffmpeg.pid') || !is_pid_running($path .'/segmenter.pid')) { $status['status'] = "error"; - $status['message'] = "Error: segmenter did not start correclty"; + $status['message'] = "Error: streaming could not start correclty"; } else { @@ -256,25 +256,23 @@ function getstreamingstatus($session) $status['message'] = "Vid: requesting " .$url .""; break; } + } - $status['message'] .= "
"; + $status['message'] .= "
"; - - $status['message'] .= "
* FFmpeg: "; - if (file_exists($path .'/ffmpeg.pid')) - $status['message'] .= "running"; - else - $status['message'] .= "stopped"; - $status['message'] .= "
* Segmenter: "; - if (file_exists($path .'/segmenter.pid')) - { - $status['message'] .= "running ("; - $status['message'] .= count(glob($path . '/*.ts')) ."/2)"; - } - else - $status['message'] .= "stopped"; - + $status['message'] .= "
* FFmpeg: "; + if (is_pid_running($path .'/ffmpeg.pid')) + $status['message'] .= "running"; + else + $status['message'] .= "stopped"; + $status['message'] .= "
* Segmenter: "; + if (is_pid_running($path .'/segmenter.pid')) + { + $status['message'] .= "running ("; + $status['message'] .= count(glob($path . '/*.ts')) ."/2)"; } + else + $status['message'] .= "stopped"; } else { @@ -284,7 +282,7 @@ function getstreamingstatus($session) $status['message'] .= "
* Quality: " .$mode .""; $status['message'] .= "
* Status: "; - if (file_exists($path .'/segmenter.pid')) + if (is_pid_running($path .'/segmenter.pid')) $status['message'] .= "encoding..."; else $status['message'] .= "fully encoded"; @@ -330,6 +328,25 @@ function sessiongetstatus($session, $prevmsg) $status['status'] = "error"; $status['message'] = "Error: session could not start"; + + $status['message'] .= "
"; + + $status['message'] .= "
* FFmpeg: "; + + if (is_pid_running('../ram/' .$session .'/ffmpeg.pid')) + $status['message'] .= "running"; + else + $status['message'] .= "stopped"; + $status['message'] .= "
* Segmenter: "; + + if (is_pid_running('../ram/' .$session .'/segmenter.pid')) + { + $status['message'] .= "running ("; + $status['message'] .= count(glob('../ram/' .$session .'/*.ts')) ."/2)"; + } + else + $status['message'] .= "stopped"; + addlog("Returning status: " .$status['message']); return $status; } @@ -382,7 +399,7 @@ function sessiongetlist() $newsession['name'] = "Error: " .$newsession['name']; // Check if encoding - if (file_exists('../ram/' .$session .'/segmenter.pid') && ($status['status'] != "error")) + if (is_pid_running('../ram/' .$session .'/segmenter.pid') && ($status['status'] != "error")) $newsession['encoding'] = 1; else $newsession['encoding'] = 0; -- cgit v1.2.3