Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Local Robo instance boostrapping
<?php
use Robo\Tasks;
/**
* Setup an ElasticSearch server locally.
*/
class RoboFile extends Tasks {
const ES_VERSION = '7.5.2';
/**
* Creates a local ElasticSearch instance.
*/
public function localEs() {
$elastic_archive = 'elasticsearch-' . self::ES_VERSION . '-linux-x86_64.tar.gz';
$directory = basename($elastic_archive, '-linux-x86_64.tar.gz');
if (!file_exists($directory)) {
$this->taskExec('wget https://artifacts.elastic.co/downloads/elasticsearch/' . $elastic_archive)->run();
$this->taskExec('tar xfz ' . $elastic_archive)->run();
}
$this->taskExec("cd $directory && bin/elasticsearch-plugin install analysis-kuromoji")->run();
$this->taskExec("cd $directory && nohup bin/elasticsearch &")->run();
$this->taskExec("while ! echo exit | nc localhost 9200; do sleep 10; done")->run();
$this->provision("http://localhost:9200", "", "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.