public function run($siteID, $args) { Task::setName('Sphinx Rebuild, Delta, Status'); Task::setDescription('Rebuilds the index, the delta and status of Sphinx indexer.'); $response = 'The following tasks were completed successfully: '; // Nightly Rebuild of entire Sphinx index at 01:00AM CST if (self::getHour() == 1 && self::getMinute() == 0) { if (!system($script = sprintf('%s/scripts/sphinx_rotate.sh', ASPUtility::getEnvironmentValue('CATS_PATH')), $result)) { $this->setResponse(sprintf('Unable to execute "%s": ', $script) . $result); return TASKRET_ERROR; } $response .= ' * Rebuilt the entire Sphinx index'; } // Check Sphinx Status every 5 minutes if (!(self::getMinute() % 5)) { if (!system($script = sprintf('%s %s/scripts/sphinxtest.php', ASPUtility::getEnvironmentValue('PHP_PATH'), ASPUtility::getEnvironmentValue('CATS_PATH')), $result)) { $this->setResponse(sprintf('Unable to execute "%s": ', $script) . $result); return TASKRET_ERROR; } if (!system($script = sprintf('%s/scripts/sphinx_restart.sh', ASPUtility::getEnvironmentValue('CATS_PATH')), $result)) { $this->setResponse(sprintf('Unable to execute "%s": ', $script) . $result); return TASKRET_ERROR; } $response .= ' * Checked Sphinx status'; } // Update Sphinx DELTA index every minute if (!system($script = sprintf('%s/scripts/sphinx_update_delta.sh', ASPUtility::getEnvironmentValue('CATS_PATH')), $result)) { $this->setResponse(sprintf('Unable to execute "%s": ', $script) . $result); return TASKRET_ERROR; } $response .= ' * Updated the Delta'; $this->setResponse($response); return TASKRET_SUCCESS; }