Commit ebaeff33 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

cmd=status will not hang

parent c152627e
...@@ -129,6 +129,24 @@ if ($cmd == "run_camogm") ...@@ -129,6 +129,24 @@ if ($cmd == "run_camogm")
} }
else if ($cmd == "status") else if ($cmd == "status")
{ {
// is camogm running
$camogm_running = "not running";
exec('ps | grep "camogm"', $arr);
function low_daemon($v)
{
return (substr($v, -1) != ']');
}
$p = (array_filter($arr, "low_daemon"));
$check = implode("<br />",$p);
if (strstr($check, $start_str))
$camogm_running = "on";
else
$camogm_running = "off";
if ($camogm_running=="on"){
$pipe="/var/state/camogm.state"; $pipe="/var/state/camogm.state";
$mode=0777; $mode=0777;
if(!file_exists($pipe)) { if(!file_exists($pipe)) {
...@@ -140,6 +158,10 @@ else if ($cmd == "status") ...@@ -140,6 +158,10 @@ else if ($cmd == "status")
fclose($fcmd); fclose($fcmd);
$status=file_get_contents($pipe); $status=file_get_contents($pipe);
}else{
$status = "<?xml version='1.0'?><camogm_state>\n<state>".$camogm_running."</state>\n</camogm_state>";
}
header("Content-Type: text/xml"); header("Content-Type: text/xml");
header("Content-Length: ".strlen($status)."\n"); header("Content-Length: ".strlen($status)."\n");
header("Pragma: no-cache\n"); header("Pragma: no-cache\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment