/** * 初始化markdown */ public function actionInit() { if (empty($this->_config['git'])) { throw new Exception('请先在Config.php中配置文档保存到的git ssh地址:)'); } if (strpos($this->_config['git'], '.git') === false) { throw new Exception('请确保Config.php中配置的git为ssh格式地址:)'); } $git = new Command(); $ret = $git->initGit($this->_config['git']); if ($ret) { $this->redirect('/'); } else { $git->cleanInitDir(); throw new Exception('初始化git文档目录失败,请确认php进程用户' . Get_Current_User() . '的ssh-key已加入git的ssh-key列表。'); } }
</td></tr> <tr><td>系统时间:</td><td><?php date_default_timezone_set(PRC); echo date("Y-m-d G:i:s"); ?> </td></tr> <tr><td>系统目录:</td><td><?php echo $_SERVER['SystemRoot']; ?> </td></tr> <tr><td>虚拟主机域名:</td><td><?php echo $_SERVER['SERVER_NAME']; ?> </td></tr> <tr><td>当前进程用户:</td><td><?php echo Get_Current_User(); ?> </td></tr> <tr><td>本文件路径:</td><td><?php echo __FILE__; ?> </td></tr> </table> <?php dialogend('FC-System Computer Inc'); ?> <br/> <?php dialogbegin('PHP环境信息'); ?>
/** * 项目配置检测,提前发现配置不当之处。 * * @return string */ public function actionDetection($projectId) { $project = Project::getConf($projectId); $log = []; $code = 0; // 本地git ssh-key是否加入deploy-keys列表 $revision = Repo::getRevision($project->repo_type); try { $ret = $revision->setConfig($project)->updateRepo(); if (!$ret) { $code = -1; $error = $project->repo_type == Project::REPO_GIT ? '把ssh-key加入git的deploy-keys列表' : '用户名密码无误'; $log[] = sprintf('宿主机代码检出检测出错,请确认php进程用户%s有代码存储仓库%s读写权限, 并且%s。详细错误:%s<br>', Get_Current_User(), $project->deploy_from, $error, $revision->getExeLog()); } } catch (\Exception $e) { $code = -1; $log[] = sprintf('宿主机检测时发生系统错误:%s<br>', $e->getMessage()); } // 权限与免密码登录检测 $task = new WalleTask(); try { $task->setConfig($project); $command = sprintf('mkdir -p %s', Project::getReleaseVersionDir('detection')); $ret = $task->runRemoteTaskCommandPackage([$command]); if (!$ret) { $code = -1; $log[] = sprintf('目标机器代码检出检测出错,请确认php进程用户%s用户ssh-key加入目标机器的%s用户ssh-key信任列表, 且%s有目标机器发布版本库%s写入权限。详细错误:%s<br>', Get_Current_User(), $project->release_user, $project->release_user, $project->release_to, $task->getExeLog()); } // 清除 $command = sprintf('rm -rf %s', Project::getReleaseVersionDir('detection')); $task->runRemoteTaskCommandPackage([$command]); } catch (\Exception $e) { $code = -1; $log[] = sprintf('目标机检测时发生系统错误:%s<br>', $e->getMessage()); } // task 检测todo... if ($code === 0) { $log[] = '配置检测通过,恭喜:)'; } $this->renderJson(join("<br>", $log), $code); }