diff --git a/hyproxy-cli.php b/hyproxy-cli.php index c3261ab..8a7099c 100644 --- a/hyproxy-cli.php +++ b/hyproxy-cli.php @@ -114,12 +114,26 @@ hy_deldir(_HYCONF);//删除所有 } foreach ($list as $row) { - $filebytes = false; + //定义日志完整路径 + $row['access_log_path'] = _HYLOGS . $row['server_name'] . '.access.log'; + $row['error_log_path'] = _HYLOGS . $row['server_name'] . '.error.log'; + //构建conf内容 $conf = hy_build_nginx_conf($row); + + //文件操作 + $filebytes = false; if (!$row['status']=='start') { $filebytes = unlink(_HYCONF.$row['server_name'].'.conf');//删除 } elseif (!empty($conf)) { $filebytes = file_put_contents(_HYCONF.$row['server_name'].'.conf', $conf); //写入内容 + //access_log_path不存在的话创建 + if (file_exists(!$row['access_log_path'])) { + file_put_contents($row['access_log_path'], ''); + } + //error_log_path不存在的话创建 + if (file_exists(!$row['error_log_path'])) { + file_put_contents($row['error_log_path'], ''); + } } if ($filebytes) { @@ -380,11 +394,7 @@ } $conf = false; - if (!empty($row)) { - //定义日志完整路径 - $row['access_log_path'] = _HYLOGS . $row['server_name'] . '.access.log'; - $row['error_log_path'] = _HYLOGS . $row['server_name'] . '.error.log'; - + if (!empty($row['server_name'])) { //判断使用哪个模板 $template = false; if (!empty($row['proxy_cache']) && !empty($proxy_cache_template)) {