本文整理汇总了PHP中app\models\Project::getReleaseVersionPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::getReleaseVersionPackage方法的具体用法?PHP Project::getReleaseVersionPackage怎么用?PHP Project::getReleaseVersionPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Project
的用法示例。
在下文中一共展示了Project::getReleaseVersionPackage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyFiles
/**
* 将多个文件/目录通过ansible传输到指定的多个目标机
*
* ansible 不支持 rsync模块, 改用宿主机 tar 打包, ansible 并发传输到目标机临时目录, 目标机解压
*
* @param $version
* @param string $files 相对仓库文件/目录路径, 空格分割
* @param array $remoteHosts
*/
public function copyFiles($version, $files = '*', $remoteHosts = [])
{
// 1. 打包
$excludes = GlobalHelper::str2arr($this->getConfig()->excludes);
$packagePath = Project::getDeployPackagePath($version);
$packageCommand = sprintf('cd %s && tar -p %s -cz -f %s %s', escapeshellarg(rtrim(Project::getDeployWorkspace($version), '/') . '/'), $this->excludes($excludes), escapeshellarg($packagePath), $files);
$ret = $this->runLocalCommand($packageCommand);
if (!$ret) {
return false;
}
// 2. 传输文件
$releasePackage = Project::getReleaseVersionPackage($version);
$ret = $this->copyFilesByAnsibleCopy($packagePath, $releasePackage);
if (!$ret) {
return false;
}
// 3. 解压
$releasePath = Project::getReleaseVersionDir($version);
$unpackageCommand = sprintf('cd %1$s && tar --no-same-owner -pm -C %1$s -xz -f %2$s', $releasePath, $releasePackage);
$ret = $this->runRemoteCommandByAnsibleShell($unpackageCommand);
return $ret;
}
示例2: _unpackageFilesByAnsible
/**
* @param Project $project
* @param TaskModel $task
* @return bool
* @throws \Exception
*/
protected function _unpackageFilesByAnsible(Project $project, TaskModel $task)
{
$version = $task->link_id;
$releasePackage = Project::getReleaseVersionPackage($version);
$webrootPath = Project::getTargetWorkspace();
$releasePath = Project::getReleaseVersionDir($version);
$cmd = [];
if ($task->file_transmission_mode == TaskModel::FILE_TRANSMISSION_MODE_PART) {
// 增量传输时, 在解压数据包之前, 需要把目标机当前版本复制一份到release目录
$cmd[] = sprintf('cp -arf %s/. %s', $webrootPath, $releasePath);
}
$cmd[] = sprintf('cd %1$s && tar --no-same-owner -pm -C %1$s -xz -f %2$s', $releasePath, $releasePackage);
$command = join(' && ', $cmd);
$ret = $this->runRemoteCommandByAnsibleShell($command);
if (!$ret) {
throw new \Exception(yii::t('walle', 'unpackage error'));
}
return true;
}