コード例 #1
0
ファイル: Log.php プロジェクト: walkor/workerman-bench
 /**
  * 检查log目录是否可写
  * @return bool
  */
 public static function checkWriteable()
 {
     $ok = true;
     if (!is_dir(WORKERMAN_LOG_DIR)) {
         // 检查log目录是否可读
         umask(0);
         if (@mkdir(WORKERMAN_LOG_DIR, 0777) === false) {
             $ok = false;
         }
         @chmod(WORKERMAN_LOG_DIR, 0777);
     }
     if (!is_readable(WORKERMAN_LOG_DIR) || !is_writeable(WORKERMAN_LOG_DIR)) {
         $ok = false;
     }
     if (!$ok) {
         $pad_length = 26;
         Master::notice(WORKERMAN_LOG_DIR . " Need to have read and write permissions\tWorkerman start fail");
         exit("------------------------LOG------------------------\n" . str_pad(WORKERMAN_LOG_DIR, $pad_length) . " [NOT READABLE/WRITEABLE] \n\nDirectory " . WORKERMAN_LOG_DIR . " Need to have read and write permissions\n\nWorkerman start fail\n\n");
     }
 }