set timeout for external commands when creating fulltext index

This commit is contained in:
Uwe Steinmann 2015-08-05 21:11:21 +02:00
parent 5a22a51943
commit 7485a85077
5 changed files with 24 additions and 5 deletions

View File

@ -179,6 +179,8 @@ class Settings { /* {{{ */
var $_adminIP = ""; var $_adminIP = "";
// Max Execution Time // Max Execution Time
var $_maxExecutionTime = null; var $_maxExecutionTime = null;
// command timeout
var $_cmdTimeout = 5;
// Preview image width in lists // Preview image width in lists
var $_previewWidthList = 40; var $_previewWidthList = 40;
// Preview image width on document details page // Preview image width on document details page
@ -508,6 +510,7 @@ class Settings { /* {{{ */
$this->_contentOffsetDir = strval($tab["contentOffsetDir"]); $this->_contentOffsetDir = strval($tab["contentOffsetDir"]);
$this->_maxDirID = intval($tab["maxDirID"]); $this->_maxDirID = intval($tab["maxDirID"]);
$this->_updateNotifyTime = intval($tab["updateNotifyTime"]); $this->_updateNotifyTime = intval($tab["updateNotifyTime"]);
$this->_cmdTimeout = intval($tab["cmdTimeout"]);
if (isset($tab["maxExecutionTime"])) if (isset($tab["maxExecutionTime"]))
$this->_maxExecutionTime = intval($tab["maxExecutionTime"]); $this->_maxExecutionTime = intval($tab["maxExecutionTime"]);
else else
@ -765,6 +768,7 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "maxDirID", $this->_maxDirID); $this->setXMLAttributValue($node, "maxDirID", $this->_maxDirID);
$this->setXMLAttributValue($node, "updateNotifyTime", $this->_updateNotifyTime); $this->setXMLAttributValue($node, "updateNotifyTime", $this->_updateNotifyTime);
$this->setXMLAttributValue($node, "maxExecutionTime", $this->_maxExecutionTime); $this->setXMLAttributValue($node, "maxExecutionTime", $this->_maxExecutionTime);
$this->setXMLAttributValue($node, "cmdTimeout", $this->_cmdTimeout);
// XML Path: /configuration/advanced/converters // XML Path: /configuration/advanced/converters
foreach($this->_converters['fulltext'] as $mimeType => $cmd) foreach($this->_converters['fulltext'] as $mimeType => $cmd)

View File

@ -162,6 +162,7 @@ if ($action == "saveSettings")
$settings->_maxDirID = intval($_POST["maxDirID"]); $settings->_maxDirID = intval($_POST["maxDirID"]);
$settings->_updateNotifyTime = intval($_POST["updateNotifyTime"]); $settings->_updateNotifyTime = intval($_POST["updateNotifyTime"]);
$settings->_maxExecutionTime = intval($_POST["maxExecutionTime"]); $settings->_maxExecutionTime = intval($_POST["maxExecutionTime"]);
$settings->_cmdTimeout = (intval($_POST["cmdTimeout"]) > 0) ?intval($_POST["cmdTimeout"]) : 1;
// SETTINGS - ADVANCED - INDEX CMD // SETTINGS - ADVANCED - INDEX CMD
$settings->_converters['fulltext'] = $_POST["converters"]; $settings->_converters['fulltext'] = $_POST["converters"];

View File

@ -65,7 +65,7 @@ else {
$folder = $dms->getFolder($folderid); $folder = $dms->getFolder($folderid);
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'index'=>$index, 'recreate'=>(isset($_GET['create']) && $_GET['create']==1), 'folder'=>$folder, 'converters'=>$settings->_converters['fulltext'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'index'=>$index, 'recreate'=>(isset($_GET['create']) && $_GET['create']==1), 'folder'=>$folder, 'converters'=>$settings->_converters['fulltext'], 'timeout'=>$settings->_cmdTimeout));
if($view) { if($view) {
$view->show(); $view->show();
exit; exit;

View File

@ -43,8 +43,12 @@ class SeedDMS_View_Indexer extends SeedDMS_Bootstrap_Style {
echo $indent." ".$document->getId().":".htmlspecialchars($document->getName())." "; echo $indent." ".$document->getId().":".htmlspecialchars($document->getName())." ";
/* If the document wasn't indexed before then just add it */ /* If the document wasn't indexed before then just add it */
if(!($hits = $index->find('document_id:'.$document->getId()))) { if(!($hits = $index->find('document_id:'.$document->getId()))) {
$index->addDocument(new SeedDMS_Lucene_IndexedDocument($dms, $document, $this->converters ? $this->converters : null)); try {
echo "(document added)"; $index->addDocument(new SeedDMS_Lucene_IndexedDocument($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
echo "(document added)";
} catch(Exception $e) {
echo $indent."(adding document failed '".$e->getMessage()."')";
}
} else { } else {
$hit = $hits[0]; $hit = $hits[0];
/* Check if the attribute created is set or has a value older /* Check if the attribute created is set or has a value older
@ -62,8 +66,13 @@ class SeedDMS_View_Indexer extends SeedDMS_Bootstrap_Style {
echo $indent."(document unchanged)"; echo $indent."(document unchanged)";
} else { } else {
$index->delete($hit->id); $index->delete($hit->id);
$index->addDocument(new SeedDMS_Lucene_IndexedDocument($dms, $document, $this->converters ? $this->converters : null)); try {
echo $indent."(document updated)"; $index->addDocument(new SeedDMS_Lucene_IndexedDocument($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
echo $indent."(document updated)";
} catch(Exception $e) {
print_r($e);
echo $indent."(updating document failed)";
}
} }
} }
echo "\n"; echo "\n";
@ -77,6 +86,7 @@ class SeedDMS_View_Indexer extends SeedDMS_Bootstrap_Style {
$recreate = $this->params['recreate']; $recreate = $this->params['recreate'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
$this->converters = $this->params['converters']; $this->converters = $this->params['converters'];
$this->timeout = $this->params['timeout'];
$this->htmlStartPage(getMLText("admin_tools")); $this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation(); $this->globalNavigation();

View File

@ -561,6 +561,10 @@ if(!is_writeable($settings->_configFilePath)) {
<td><?php printMLText("settings_maxExecutionTime");?>:</td> <td><?php printMLText("settings_maxExecutionTime");?>:</td>
<td><input type="text" name="maxExecutionTime" value="<?php echo $settings->_maxExecutionTime ?>" /></td> <td><input type="text" name="maxExecutionTime" value="<?php echo $settings->_maxExecutionTime ?>" /></td>
</tr> </tr>
<tr title="<?php printMLText("settings_cmdTimeout_desc");?>">
<td><?php printMLText("settings_cmdTimeout");?>:</td>
<td><input type="text" name="cmdTimeout" value="<?php echo $settings->_cmdTimeout ?>" /></td>
</tr>
<tr ><td><b> <?php printMLText("index_converters");?></b></td> </tr> <tr ><td><b> <?php printMLText("index_converters");?></b></td> </tr>
<?php <?php