Przeglądaj źródła

Instrumented the code to help in solving the "restore runing" issue. We've added traces into the error.log file:
- Log restore begin/end
- Log if detecting that a restore is running (and displaying the banner)
- Log any Exception occuring during the detection (instead of just ignoring it)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3733 a333f486-631f-4898-b8df-5754b55c2be0

romainq 10 lat temu
rodzic
commit
0122952eb4

+ 5 - 2
datamodels/2.x/itop-backup/ajax.backup.php

@@ -1,5 +1,5 @@
 <?php
-// Copyright (C) 2014 Combodo SARL
+// Copyright (C) 2013-2015 Combodo SARL
 //
 //   This file is part of iTop.
 //
@@ -19,7 +19,7 @@
 /**
  * Backup from an interactive session
  *
- * @copyright   Copyright (C) 2013 Combodo SARL
+ * @copyright   Copyright (C) 2013-215 Combodo SARL
  * @license     http://opensource.org/licenses/AGPL-3.0
  */
 
@@ -119,7 +119,9 @@ EOF
 		{
 			$sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
 			$oRestoreMutex = new iTopMutex('restore.'.$sEnvironment);
+			IssueLog::Info("Backup Restore - Acquiring the LOCK 'restore.$sEnvironment'");
 			$oRestoreMutex->Lock();
+			IssueLog::Info('Backup Restore - LOCK acquired, executing...');
 			try
 			{
 				set_time_limit(0);
@@ -148,6 +150,7 @@ EOF
 				$sBackupFile = $sBackupDir.$sFile;
 				$sRes = $oDBRS->RestoreFromZip($sBackupFile, $sEnvironment);
 	
+				IssueLog::Info('Backup Restore - Done, releasing the LOCK');
 				$oRestoreMutex->Unlock();
 			}
 			catch (Exception $e)

+ 3 - 3
datamodels/2.x/itop-backup/main.itop-backup.php

@@ -1,5 +1,5 @@
 <?php
-// Copyright (C) 2014 Combodo SARL
+// Copyright (C) 2014-2015 Combodo SARL
 //
 //   This program is free software; you can redistribute it and/or modify
 //   it under the terms of the GNU General Public License as published by
@@ -26,7 +26,6 @@ class BackupHandler extends ModuleHandlerAPI
 {
 	public static function OnMetaModelStarted()
 	{
-
 		try
 		{
 			$oBackupMutex = new iTopMutex('backup.'.utils::GetCurrentEnvironment());
@@ -48,13 +47,14 @@ class BackupHandler extends ModuleHandlerAPI
 			}
 			else
 			{
+				IssueLog::Info(__class__.'::'.__function__.' A user is trying to use iTop while a restore is running. The requested page is in read-only mode.');
 				MetaModel::GetConfig()->Set('access_mode', ACCESS_READONLY, 'itop-backup');
 				MetaModel::GetConfig()->Set('access_message', ' - '.dict::S('bkp-restore-running'), 'itop-backup');
 			}
 		}
 		catch(Exception $e)
 		{
-			
+			IssueLog::Error(__class__.'::'.__function__.' Failed to check if a backup/restore is running: '.$e->getMessage());
 		}
 	}
 }