/** * 解析启动模式参数 * @param $opt */ public static function params_s($opt) { //判断传入了s参数但是值,则提示错误 if (isset($opt["s"]) && !$opt["s"] || isset($opt["s"]) && !in_array($opt["s"], array("start", "stop", "restart"))) { Main::log_write("Please run: path/to/php main.php -s [start|stop|restart]"); } if (isset($opt["s"]) && in_array($opt["s"], array("start", "stop", "restart"))) { switch ($opt["s"]) { case "start": Crontab::start(); break; case "stop": Crontab::stop(); break; case "restart": Crontab::restart(); break; } } }
/** *启动 *@param $opt */ public static function options_s($opt) { if (isset($opt['s']) && !$opt['s'] || isset($opt['s']) && !in_array($opt['s'], self::$optionSList)) { exit("-s参数错误,-s start/stop/restart/reload\n"); } if (isset($opt['s']) && in_array($opt['s'], self::$optionSList)) { switch ($opt['s']) { case 'start': echo "正在启动服务中...\n"; sleep(1); Crontab::start(); break; case 'stop': echo "正在停止服务...\n"; sleep(1); Crontab::stop(); break; case 'restart': echo "正在重启服务...\n"; sleep(1); Crontab::restart(); break; case 'reload': Crontab::reload(); break; } } }