-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Add grunt-task to build ES from source #8866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import childProcess from 'child_process'; | ||
| import bluebird from 'bluebird'; | ||
|
|
||
| const runCommand = bluebird.promisify(childProcess.exec); | ||
| const runFile = bluebird.promisify(childProcess.execFile); | ||
| const esRepo = `../elasticsearch/`; | ||
| const esDest = `${esRepo}distribution/tar/build/distributions/`; | ||
|
|
||
| /** | ||
| * EXPERIMENTAL | ||
| * | ||
| * Build ES from source and startup. It ensures Kibana and Elasticsearch share the same major branch. | ||
| * | ||
| * The setup requires Kibana and Elasticsearch are on the same directory level | ||
| * | ||
| * Limitations: | ||
| * - *NIX only. | ||
| * - X-plugins not yet supported | ||
| * | ||
| * @param grunt | ||
| */ | ||
| module.exports = function (grunt) { | ||
|
|
||
| grunt.registerTask('es-start', async function () { | ||
|
|
||
| const taskDone = this.async(); | ||
| const currentLocation = await runCommand('pwd'); | ||
|
|
||
| try { | ||
| const kibanaTags = await runCommand('git tag'); | ||
| const elasticTags = await runCommand(`cd ${esRepo} && git tag`); | ||
| const kibanaMajor = getMajorVersion(kibanaTags[0]); | ||
| const elasticsearchMajor = getMajorVersion(elasticTags[0]); | ||
|
|
||
| console.log('Ensuring major branches are the same.'); | ||
| if (kibanaMajor !== elasticsearchMajor) { | ||
| const message = `Kibana and Elasticsearch must be on | ||
| the same major branch: Kibana=${kibanaMajor}, Elasticsearch=${elasticsearchMajor}`; | ||
| throw new Error(message); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts on whether it should also do a git pull from the upstream repo? |
||
|
|
||
| if (kibanaMajor < 5) { | ||
| throw new Error('Must at least be at version 5'); | ||
| } | ||
|
|
||
|
|
||
| console.log('Building Elasticsearch. This may take a while if this is the first time.'); | ||
| try { | ||
| await runCommand('cd ../elasticsearch && gradle assemble -x test'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we only plan to build and run we can also use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This command will build the docs as well, which takes a long time and isn't really needed. It will also build the zip distribution, which isn't used in this scirpt. Maybe change to:
That will skip running the tests as well, which it looks like you want to do |
||
| } catch (e) { | ||
| throw new Error('Could not build ElasticSearch'); | ||
| } | ||
|
|
||
| const distrib = await runCommand(`find ${esRepo}distribution/tar/build/distributions/elasticsearch*.tar.gz`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably use |
||
| const zipFile = distrib[0].trim(); | ||
| console.log('Unpacking ES'); | ||
| await runCommand(`tar -xzvf ${zipFile} -C ${esDest}`); | ||
|
|
||
|
|
||
| let esDistro = await runCommand(`find ${esDest} -name 'elasticsearch*' -type d`); | ||
| esDistro = esDistro[0].trim(); | ||
| console.log('Starting ES'); | ||
| await runFile(`${esDistro}/bin/elasticsearch`); | ||
| } catch (e) { | ||
| console.error('Cannot start Elasticsearch.'); | ||
| console.error(e); | ||
| } finally { | ||
| console.log('Tearing down process'); | ||
| await runCommand(`cd ${currentLocation}`); | ||
| taskDone(false); | ||
| } | ||
|
|
||
|
|
||
| }); | ||
|
|
||
| }; | ||
|
|
||
| function getMajorVersion(gitResponse) { | ||
| const lines = gitResponse.split('\n').filter(s => s.startsWith('v')); | ||
| const lastTag = lines[lines.length - 1].trim(); | ||
| return parseInt(lastTag.substr(1, 1)); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export default