mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
on system:install add elasticsearch informations options
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Core\Configuration\StructureTemplate;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions;
|
||||
use Doctrine\DBAL\Driver\Connection;
|
||||
use Symfony\Component\Console\Helper\DialogHelper;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
@@ -51,7 +52,9 @@ class Install extends Command
|
||||
->addOption('db-template', null, InputOption::VALUE_OPTIONAL, 'Databox template (' . $this->structureTemplate->toString() . ')', null)
|
||||
->addOption('data-path', null, InputOption::VALUE_OPTIONAL, 'Path to data repository', realpath(__DIR__ . '/../../../../../datas'))
|
||||
->addOption('server-name', null, InputOption::VALUE_OPTIONAL, 'Server name')
|
||||
->addOption('indexer', null, InputOption::VALUE_OPTIONAL, 'Path to Phraseanet Indexer', 'auto')
|
||||
->addOption('es-host', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP host', 'localhost')
|
||||
->addOption('es-port', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP port', 9200)
|
||||
->addOption('es-index', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch index name', null)
|
||||
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions');
|
||||
|
||||
return $this;
|
||||
@@ -121,6 +124,21 @@ class Install extends Command
|
||||
list($email, $password) = $this->getCredentials($input, $output, $dialog);
|
||||
$dataPath = $this->getDataPath($input, $output, $dialog);
|
||||
|
||||
if (! $input->getOption('yes')) {
|
||||
$output->writeln("<info>--- ElasticSearch connection settings ---</info>");
|
||||
}
|
||||
|
||||
list($esHost, $esPort) = $this->getESHost($input, $output, $dialog);
|
||||
$esIndexName = $this->getESIndexName($input, $output, $dialog);
|
||||
|
||||
$esOptions = ElasticsearchOptions::fromArray([
|
||||
'host' => $esHost,
|
||||
'port' => $esPort,
|
||||
'index' => $esIndexName
|
||||
]);
|
||||
|
||||
$output->writeln('');
|
||||
|
||||
if (!$input->getOption('yes')) {
|
||||
$continue = $dialog->askConfirmation($output, "<question>Phraseanet is going to be installed, continue ? (N/y)</question>", false);
|
||||
|
||||
@@ -132,6 +150,7 @@ class Install extends Command
|
||||
}
|
||||
|
||||
$this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $templateName, $this->detectBinaries());
|
||||
$this->container['conf']->set(['main', 'search-engine', 'options'], $esOptions->toArray());
|
||||
|
||||
if (null !== $this->getApplication()) {
|
||||
$command = $this->getApplication()->find('crossdomain:generate');
|
||||
@@ -339,6 +358,35 @@ class Install extends Command
|
||||
return $serverName;
|
||||
}
|
||||
|
||||
private function getESHost(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
|
||||
{
|
||||
$host = $input->getOption('es-host');
|
||||
$port = (int) $input->getOption('es-port');
|
||||
|
||||
if (! $input->getOption('yes')) {
|
||||
while (! $host) {
|
||||
$host = $dialog->ask($output, 'ElasticSearch server host : ', null);
|
||||
};
|
||||
|
||||
while ($port <= 0 || $port >= 65535) {
|
||||
$port = (int) $dialog->ask($output, 'ElasticSearch server port : ', null);
|
||||
};
|
||||
}
|
||||
|
||||
return [ $host, $port ];
|
||||
}
|
||||
|
||||
private function getESIndexName(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
|
||||
{
|
||||
$index = $input->getOption('es-index');
|
||||
|
||||
if (! $input->getOption('yes')) {
|
||||
$index = $dialog->ask($output, 'ElasticSearch server index name (blank to autogenerate) : ', null);
|
||||
}
|
||||
|
||||
return $index;
|
||||
}
|
||||
|
||||
private function detectBinaries()
|
||||
{
|
||||
return [
|
||||
|
Reference in New Issue
Block a user