Example #1
0
 case "restart":
     if (!$port) {
         echo "No port specified\n";
         exit(0);
     }
     echo CMLLPServer::send($host, $port, "__" . strtoupper($command) . "__\n");
     break;
 case "test":
     if (!$port) {
         echo "No port specified\n";
         exit(0);
     }
     $n = 30;
     $secs = 60;
     for ($i = 0; $i < $n; $i++) {
         echo CMLLPServer::send($host, $port, "\v" . CMLLPServer::sampleMessage() . "\r");
         usleep($secs * 1000000);
     }
     break;
 case "list":
     if (!in_array($host, array("localhost", "127.0.0.1", "::1"))) {
         outln("Specified host is not local, localhost will be used instead");
     }
     $processes = CMLLPServer::getPsStatus();
     echo "--------------------------------------\n";
     echo "   PID |  PORT | STATUS | PS NAME     \n";
     echo "--------------------------------------\n";
     foreach ($processes as $_pid => $_status) {
         $_ok = isset($_status["ps_name"]) && stripos($_status["ps_name"], "php") !== false;
         $_msg = $_ok ? $msg_ok : $msg_error;
         printf(" %5.d | %5.d | %s | %s \n", $_pid, $_status["port"], $_msg, @$_status["ps_name"]);