= 2) { $cmd = $argv[1]; if ($cmd == 'start') { $daemonize = false; if ($argc == 3 && $argv[2] == '-d') { $daemonize = true; } $http = new HttpServer($daemonize); $http->run(); } else if ($cmd == 'stop') { $getpid = intval(file_get_contents("./Buddha.pid")); //获取上一次程序运行的 master_id if ($getpid && trim($getpid) != 0) { Process::kill($getpid); echo "stop success" . PHP_EOL; } } else if ($cmd == 'restart') { $getpid = intval(file_get_contents("./Buddha.pid")); //获取上一次程序运行的 master_id if ($getpid && trim($getpid) != 0) { Process::kill($getpid); sleep(1); $daemonize = false; if ($argc == 3 && isset($argv[2]) && $argv == '-d') { $daemonize = true; } $http = new HttpServer($daemonize); echo "restart done" . PHP_EOL; $http->run(); } else { echo "restart the failure" . PHP_EOL; } } else { echo '无效命令'; } }