mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 13:22:49 +00:00
no message
This commit is contained in:
parent
959b30c788
commit
b9180a4426
@ -132,7 +132,7 @@ class AppsController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/apps/update_status 04. 更新应用状态
|
||||
* @api {post} api/apps/update/status 04. 更新应用状态
|
||||
*
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup apps
|
||||
@ -145,7 +145,7 @@ class AppsController extends AbstractController
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 更新结果
|
||||
*/
|
||||
public function updateStatus()
|
||||
public function update__status()
|
||||
{
|
||||
$appName = Request::input('app_name');
|
||||
$status = Request::input('status');
|
||||
@ -172,10 +172,8 @@ class AppsController extends AbstractController
|
||||
'status' => $status
|
||||
];
|
||||
|
||||
// 如果状态是安装成功,记录完成时间
|
||||
if ($status === 'installed') {
|
||||
// todo 安装完成要更新nginx配置
|
||||
}
|
||||
// 更新nginx配置
|
||||
Apps::nginxUpdate($appName);
|
||||
|
||||
// 保存配置
|
||||
if (Apps::saveAppLocalInfo($appName, $updateData)) {
|
||||
|
||||
@ -111,30 +111,12 @@ class Apps
|
||||
$result['generate'] = $res['data'];
|
||||
|
||||
// 执行docker-compose命令
|
||||
$res = self::curl("apps/{$command}/{$appName}");
|
||||
$res = self::curl("apps/{$command}/{$appName}?callback_url=" . urlencode('http://nginx/api/apps/update/status'));
|
||||
if (Base::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$result['compose'] = $res['data'];
|
||||
|
||||
// nginx配置文件处理 // todo 要单独处理
|
||||
$nginxFile = $versionInfo['path'] . '/nginx.conf';
|
||||
$nginxTarget = base_path('docker/nginx/apps/' . $appName . '.conf');
|
||||
if (file_exists($nginxTarget)) {
|
||||
unlink($nginxTarget);
|
||||
}
|
||||
if (file_exists($nginxFile)) {
|
||||
if ($command === 'up') {
|
||||
copy($nginxFile, $nginxTarget);
|
||||
}
|
||||
// 重启nginx
|
||||
$res = self::curl("nginx/reload");
|
||||
if (Base::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$result['nginx'] = $res['data'];
|
||||
}
|
||||
|
||||
// 返回结果
|
||||
return Base::retSuccess("success", $result);
|
||||
}
|
||||
@ -150,6 +132,46 @@ class Apps
|
||||
return self::dockerComposeUp($appName, $version, 'down');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新nginx配置
|
||||
* @param string $appName
|
||||
* @return array
|
||||
*/
|
||||
public static function nginxUpdate(string $appName): array
|
||||
{
|
||||
// 获取本地安装信息
|
||||
$localInfo = self::getAppLocalInfo($appName);
|
||||
|
||||
// nginx配置文件处理
|
||||
$nginxFile = base_path('docker/apps/' . $appName . '/' . $localInfo['installed_version'] . '/nginx.conf');
|
||||
$nginxTarget = base_path('docker/nginx/apps/' . $appName . '.conf');
|
||||
$needReload = false;
|
||||
if (file_exists($nginxTarget)) {
|
||||
unlink($nginxTarget);
|
||||
$needReload = true;
|
||||
}
|
||||
if (file_exists($nginxFile) && $localInfo['status'] === 'installed') {
|
||||
copy($nginxFile, $nginxTarget);
|
||||
$res = self::curl("nginx/test");
|
||||
if (Base::isError($res)) {
|
||||
unlink($nginxTarget);
|
||||
return $res;
|
||||
}
|
||||
$needReload = true;
|
||||
}
|
||||
|
||||
// 重启nginx
|
||||
if ($needReload) {
|
||||
$res = self::curl("nginx/reload");
|
||||
if (Base::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
// 返回结果
|
||||
return Base::retSuccess("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用信息
|
||||
* @param string $appName 应用名称
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user