Skip to content

Instantly share code, notes, and snippets.

@AronNovak
Created August 5, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AronNovak/e72cfca979e98cb0a3573934a2a3dc7f to your computer and use it in GitHub Desktop.
Save AronNovak/e72cfca979e98cb0a3573934a2a3dc7f to your computer and use it in GitHub Desktop.
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