Created
August 5, 2020 11:55
-
-
Save AronNovak/e72cfca979e98cb0a3573934a2a3dc7f to your computer and use it in GitHub Desktop.
Local Robo instance boostrapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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