mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°2249 - Supportability - Updater module (split ajax calls)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1065,6 +1065,14 @@ class RunTimeEnvironment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function Rollback()
|
||||
{
|
||||
if ($this->sFinalEnv != $this->sTargetEnv)
|
||||
{
|
||||
SetupUtils::tidydir($this->sTargetEnv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the given handler method for all selected modules having an installation handler
|
||||
|
||||
@@ -19,15 +19,22 @@
|
||||
|
||||
if (!defined('__DIR__')) define('__DIR__', dirname(__FILE__));
|
||||
require_once(__DIR__.'/../approot.inc.php');
|
||||
|
||||
const EXIT_CODE_ERROR = -1;
|
||||
const EXIT_CODE_FATAL = -2;
|
||||
// early exit
|
||||
if (file_exists(READONLY_MODE_FILE))
|
||||
{
|
||||
echo "iTop is read-only. Exiting...\n";
|
||||
exit(EXIT_CODE_ERROR);
|
||||
}
|
||||
|
||||
require_once(APPROOT.'/application/application.inc.php');
|
||||
require_once(APPROOT.'/application/nicewebpage.class.inc.php');
|
||||
require_once(APPROOT.'/application/webpage.class.inc.php');
|
||||
require_once(APPROOT.'/application/clipage.class.inc.php');
|
||||
require_once(APPROOT.'/core/background.inc.php');
|
||||
|
||||
const EXIT_CODE_ERROR = -1;
|
||||
const EXIT_CODE_FATAL = -2;
|
||||
|
||||
$sConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE;
|
||||
if (!file_exists($sConfigFile))
|
||||
{
|
||||
@@ -222,7 +229,7 @@ function CronExec($oP, $aProcesses, $bVerbose)
|
||||
if (file_exists(MAINTENANCE_MODE_FILE) || file_exists(READONLY_MODE_FILE))
|
||||
{
|
||||
$oP->p("Maintenance detected, exiting");
|
||||
return;
|
||||
exit(EXIT_CODE_ERROR);
|
||||
}
|
||||
|
||||
$oTasks = new DBObjectSet($oSearch);
|
||||
|
||||
Reference in New Issue
Block a user