mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
Merge pull request #200 from creative-commoners/pulls/3.0/use-symfony-process
NEW Use symfony/process to execute immediate system commands for reindexing
This commit is contained in:
commit
10344580c9
@ -23,7 +23,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "^4.0",
|
"silverstripe/framework": "^4.0",
|
||||||
"monolog/monolog": "~1.15",
|
"monolog/monolog": "~1.15",
|
||||||
"ptcinc/solr-php-client": "^1.0"
|
"ptcinc/solr-php-client": "^1.0",
|
||||||
|
"symfony/process": "^3.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"silverstripe/cms": "^4.0",
|
"silverstripe/cms": "^4.0",
|
||||||
|
@ -8,6 +8,7 @@ use SilverStripe\Core\Manifest\ModuleLoader;
|
|||||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||||
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invokes an immediate reindex
|
* Invokes an immediate reindex
|
||||||
@ -77,11 +78,15 @@ class SolrReindexImmediateHandler extends SolrReindexBase
|
|||||||
$scriptTask = "php {$scriptPath} dev/tasks/{$taskName}";
|
$scriptTask = "php {$scriptPath} dev/tasks/{$taskName}";
|
||||||
|
|
||||||
$cmd = "{$scriptTask} index={$indexClassEscaped} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
|
$cmd = "{$scriptTask} index={$indexClassEscaped} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
|
||||||
$cmd .= " verbose=1 2>&1";
|
$cmd .= " verbose=1";
|
||||||
$logger->info("Running '$cmd'");
|
$logger->info("Running '$cmd'");
|
||||||
|
|
||||||
// Execute script via shell
|
// Execute script via shell
|
||||||
$res = $logger ? passthru($cmd) : `$cmd`;
|
$process = new Process($cmd);
|
||||||
|
$process->inheritEnvironmentVariables();
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$res = $process->getOutput();
|
||||||
if ($logger) {
|
if ($logger) {
|
||||||
$logger->info(preg_replace('/\r\n|\n/', '$0 ', $res));
|
$logger->info(preg_replace('/\r\n|\n/', '$0 ', $res));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user