From 36c875fde8bd557eacbac353c4f8dca059b69be6 Mon Sep 17 00:00:00 2001 From: hitsword Date: Thu, 9 Jan 2020 20:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96make=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=88=A4=E6=96=AD=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=EF=BC=8C=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E5=88=99=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hitsword --- hyproxy-cli.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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)) {