adapt hub code to use another env thant production

This commit is contained in:
odain
2024-09-11 15:35:17 +02:00
parent 4a99afae3b
commit cd41eda29d
3 changed files with 32 additions and 30 deletions

View File

@@ -36,6 +36,7 @@ require_once(APPROOT.'core/dict.class.inc.php');
require_once(APPROOT.'setup/xmldataloader.class.inc.php');
require_once(__DIR__.'/hubruntimeenvironment.class.inc.php');
/**
* Overload of DBBackup to handle logging
*/
@@ -166,7 +167,7 @@ try
$sLanguage = utils::ReadParam('language', '');
if ($sLanguage!='')
{
foreach (glob(APPROOT.'env-production/dictionaries/*.dict.php') as $sFilePath)
foreach (glob(APPROOT.'env-'. utils::GetCurrentEnvironment(). '/dictionaries/*.dict.php') as $sFilePath)
{
require_once ($sFilePath);
}
@@ -256,6 +257,7 @@ try
break;
case 'compile':
SetupLog::Info('Deployment starts...');
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent'))
@@ -266,13 +268,13 @@ try
$aSelectedExtensionCodes = utils::ReadParam('extension_codes', array());
$aSelectedExtensionDirs = utils::ReadParam('extension_dirs', array());
$oRuntimeEnv = new HubRunTimeEnvironment('production', false); // use a temp environment: production-build
$oRuntimeEnv = new HubRunTimeEnvironment(utils::GetCurrentEnvironment(), false); // use a temp environment: production-build
$oRuntimeEnv->MoveSelectedExtensions(APPROOT.'/data/downloaded-extensions/', $aSelectedExtensionDirs);
$oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE);
$oConfig = new Config(APPCONF.utils::GetCurrentEnvironment().'/'.ITOP_CONFIG_FILE);
if ($oConfig->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode');
$aSelectModules = $oRuntimeEnv->CompileFrom('production', false); // WARNING symlinks does not seem to be compatible with manual Commit
$aSelectModules = $oRuntimeEnv->CompileFrom(utils::GetCurrentEnvironment(), false); // WARNING symlinks does not seem to be compatible with manual Commit
$oRuntimeEnv->UpdateIncludes($oConfig);
@@ -295,7 +297,7 @@ try
case 'move_to_production':
// Second step: update the schema and the data
// Everything happening below is based on env-production
$oRuntimeEnv = new RunTimeEnvironment('production', true);
$oRuntimeEnv = new RunTimeEnvironment(utils::GetCurrentEnvironment(), true);
try
{
@@ -307,7 +309,7 @@ try
}
unlink(APPROOT.'data/hub/compile_authent');
// Load the "production" config file to clone & update it
$oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE);
$oConfig = new Config(APPCONF.utils::GetCurrentEnvironment().'/'.ITOP_CONFIG_FILE);
SetupUtils::EnterReadOnlyMode($oConfig);
$oRuntimeEnv->InitDataModel($oConfig, true /* model only */);
@@ -375,7 +377,7 @@ try
unlink(APPROOT.'data/hub/compile_authent');
}
// Note: at this point, the dictionnary is not necessarily loaded
SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage());
SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted'), null, [$e->getMessage(), $e->getTraceAsString()]);
SetupLog::Error('Debug trace: '.$e->getTraceAsString());
ReportError($e->getMessage(), $e->getCode());
}
@@ -391,7 +393,7 @@ try
}
catch (Exception $e)
{
SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage());
SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted'), null, [$e->getMessage(), $e->getTraceAsString()]);
SetupLog::Error('Debug trace: '.$e->getTraceAsString());
utils::PopArchiveMode();

View File

@@ -20,7 +20,7 @@ function DisplayStatus(WebPage $oPage)
if (is_dir($sPath)) {
$aExtraDirs[] = $sPath; // Also read the extra downloaded-modules directory
}
$oExtensionsMap = new iTopExtensionsMap('production', true, $aExtraDirs);
$oExtensionsMap = new iTopExtensionsMap(utils::GetCurrentEnvironment(), true, $aExtraDirs);
$oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig());
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
@@ -156,7 +156,7 @@ function DoInstall(WebPage $oPage)
if (is_dir($sPath)) {
$aExtraDirs[] = $sPath; // Also read the extra downloaded-modules directory
}
$oExtensionsMap = new iTopExtensionsMap('production', true, $aExtraDirs);
$oExtensionsMap = new iTopExtensionsMap(utils::GetCurrentEnvironment(), true, $aExtraDirs);
$oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig());
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {