N°2249 - Supportability - Updater module (split ajax calls)

This commit is contained in:
Eric
2020-01-15 15:48:54 +01:00
parent 956b597e50
commit 5be800cfce
5 changed files with 121 additions and 11 deletions

View File

@@ -155,6 +155,24 @@ class AjaxController extends Controller
$this->DisplayJSONPage($aParams, $iResponseCode);
}
public function OperationCheckCompile()
{
$aParams = array();
try
{
CoreUpdater::CheckCompile();
$iResponseCode = 200;
}
catch (Exception $e)
{
IssueLog::Error("Compile: ".$e->getMessage());
$aParams['sError'] = $e->getMessage();
$iResponseCode = 500;
}
$this->DisplayJSONPage($aParams, $iResponseCode);
}
public function OperationCompile()
{
$aParams = array();
@@ -163,7 +181,25 @@ class AjaxController extends Controller
CoreUpdater::Compile();
$iResponseCode = 200;
}
catch (Exception $e)
catch (Exception $e)
{
IssueLog::Error("Compile: ".$e->getMessage());
$aParams['sError'] = $e->getMessage();
$iResponseCode = 500;
}
$this->DisplayJSONPage($aParams, $iResponseCode);
}
public function OperationUpdateDatabase()
{
$aParams = array();
try
{
CoreUpdater::UpdateUpdateDatabase();
$iResponseCode = 200;
}
catch (Exception $e)
{
IssueLog::Error("Compile: ".$e->getMessage());
$aParams['sError'] = $e->getMessage();

View File

@@ -92,6 +92,39 @@ final class CoreUpdater
}
}
/**
* @throws \Exception
*/
public static function CheckCompile()
{
try
{
// Compile code
SetupLog::Info('itop-core-update: Start checking compilation');
$sFinalEnv = 'production';
$oRuntimeEnv = new RunTimeEnvironmentCoreUpdater($sFinalEnv, false);
$oRuntimeEnv->CheckDirectories($sFinalEnv);
$oRuntimeEnv->CompileFrom('production');
$oRuntimeEnv->Rollback();
SetupLog::Info('itop-core-update: Checking compilation done');
}
catch (Exception $e)
{
SetupLog::error($e->getMessage());
try
{
SetupUtils::ExitReadOnlyMode();
} catch (Exception $e1)
{
IssueLog::Error("ExitMaintenance: ".$e1->getMessage());
}
throw $e;
}
}
/**
* @throws \Exception
*/
@@ -103,9 +136,37 @@ final class CoreUpdater
SetupLog::Info('itop-core-update: Start compilation');
$sFinalEnv = 'production';
$oRuntimeEnv = new RunTimeEnvironmentCoreUpdater($sFinalEnv, false);
$oRuntimeEnv = new RunTimeEnvironmentCoreUpdater($sFinalEnv, true);
$oRuntimeEnv->CheckDirectories($sFinalEnv);
$oRuntimeEnv->CompileFrom('production');
SetupLog::Info('itop-core-update: Compilation done');
}
catch (Exception $e)
{
SetupLog::error($e->getMessage());
try
{
SetupUtils::ExitReadOnlyMode();
} catch (Exception $e1)
{
IssueLog::Error("ExitMaintenance: ".$e1->getMessage());
}
throw $e;
}
}
/**
* @throws \Exception
*/
public static function UpdateDatabase()
{
try
{
SetupLog::Info('itop-core-update: Start Update database');
$sFinalEnv = 'production';
$oRuntimeEnv = new RunTimeEnvironmentCoreUpdater($sFinalEnv, true);
$oConfig = $oRuntimeEnv->MakeConfigFile($sFinalEnv.' (built on '.date('Y-m-d').')');
$oConfig->Set('access_mode', ACCESS_FULL);
$oRuntimeEnv->WriteConfigFileSafe($oConfig);
@@ -156,9 +217,7 @@ final class CoreUpdater
$oRuntimeEnv->RecordInstallation($oConfig, $sDataModelVersion, $aSelectedModules,
$aSelectedExtensionCodes, 'Done by the iTop Core Updater');
$oRuntimeEnv->Commit();
SetupLog::Info('itop-core-update: Compilation done');
SetupLog::Info('itop-core-update: Update database done');
}
catch (Exception $e)
{

View File

@@ -57,7 +57,7 @@ function GetAjaxRequest(sOperation)
return oAjaxRequest;
}
{% set aSteps = ['EnterMaintenance', 'Backup', 'FilesArchive', 'CopyFiles', 'Compile', 'ExitMaintenance', 'UpdateDone'] %}
{% set aSteps = ['EnterMaintenance', 'Backup', 'FilesArchive', 'CopyFiles', 'CheckCompile', 'Compile', 'UpdateDatabase', 'ExitMaintenance', 'UpdateDone'] %}
aStepsName = [];
@@ -75,7 +75,7 @@ var sFilesArchiveStep;
sFilesArchiveStep = "FilesArchive";
{% endif %}
var aStepsAjaxOperation = ["EnterMaintenance", sBackupStep, sFilesArchiveStep, "CopyFiles", "Compile", "ExitMaintenance", null];
var aStepsAjaxOperation = ["EnterMaintenance", sBackupStep, sFilesArchiveStep, "CopyFiles", "CheckCompile", "Compile", "UpdateDatabase", "ExitMaintenance", null];
var iNextStep = 0;
function ExecNextStep() {