mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-26 21:18:04 +00:00
Better leader check
This commit is contained in:
@@ -3,9 +3,6 @@ FROM rancher/docs:build
|
|||||||
VOLUME /usr/share/nginx/html/docs
|
VOLUME /usr/share/nginx/html/docs
|
||||||
WORKDIR /run
|
WORKDIR /run
|
||||||
|
|
||||||
ADD https://github.com/rancher/giddyup/releases/download/v0.19.0/giddyup /usr/bin/giddyup
|
|
||||||
RUN chmod +x /usr/bin/giddyup
|
|
||||||
|
|
||||||
COPY gulpfile.babel.js /run/
|
COPY gulpfile.babel.js /run/
|
||||||
|
|
||||||
ENTRYPOINT ["gulp"]
|
ENTRYPOINT ["gulp"]
|
||||||
|
|||||||
+27
-23
@@ -17,6 +17,7 @@ const fs = require('fs');
|
|||||||
|
|
||||||
const $ = gulpLoadPlugins();
|
const $ = gulpLoadPlugins();
|
||||||
const browserSync = require('browser-sync').create();
|
const browserSync = require('browser-sync').create();
|
||||||
|
const request = require('request');
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
process.on('SIGINT', (err) => {
|
process.on('SIGINT', (err) => {
|
||||||
@@ -29,10 +30,6 @@ process.on('uncaughtException', (err) => {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&')
|
|
||||||
console.log(process.env)
|
|
||||||
console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&')
|
|
||||||
|
|
||||||
// --
|
// --
|
||||||
gulp.task('dev', ['build-dev'], () => {
|
gulp.task('dev', ['build-dev'], () => {
|
||||||
gulp.start('init-watch');
|
gulp.start('init-watch');
|
||||||
@@ -194,26 +191,33 @@ gulp.task('publish:search-index', (cb) => {
|
|||||||
env: env
|
env: env
|
||||||
};
|
};
|
||||||
|
|
||||||
|
request.get({url: 'http://rancher-metadata/2015-07-25/self/service/containers/0', timeout: 2000}, function(err, res, first) {
|
||||||
|
if ( err ) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Waiting');
|
request.get({url: 'http://rancher-metadata/2015-07-25/self/container/name', timeout: 2000}, function(err, res, me) {
|
||||||
setTimeout(() => {
|
if ( err ) {
|
||||||
console.log('Done');
|
return cb(err);
|
||||||
exec('giddyup leader check', opts, function(err, stdout, stderr) {
|
|
||||||
console.log('Error:', err);
|
|
||||||
console.log('Stdout:', stdout);
|
|
||||||
console.log('Stderr:', stderr);
|
|
||||||
}).on('close', code => {
|
|
||||||
if (code === 0) {
|
|
||||||
console.log('Publishing to algolia', process.env.ALGOLIA_INDEX_NAME);
|
|
||||||
atomicalgolia(process.env.ALGOLIA_INDEX_NAME, process.env.ALGOLIA_INDEX_FILE, {verbose: true}, (err, result) => {
|
|
||||||
console.log(result);
|
|
||||||
cb(err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('I am not the leader (' + code + ')');
|
|
||||||
cb(new Error('Not the leader'));
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
|
console.log('First:', first);
|
||||||
|
console.log('Me:', me);
|
||||||
|
|
||||||
|
if ( !first || !me ) {
|
||||||
|
return cb(new Error('Unable to determine who is the leader (' + first + ', ' + me+ ')'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( first !== me ) {
|
||||||
|
console.log('I am not the leader');
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Publishing to algolia', process.env.ALGOLIA_INDEX_NAME);
|
||||||
|
atomicalgolia(process.env.ALGOLIA_INDEX_NAME, process.env.ALGOLIA_INDEX_FILE, {verbose: true}, (err, result) => {
|
||||||
|
console.log(result);
|
||||||
|
cb(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"moment": "^2.20.1",
|
"moment": "^2.20.1",
|
||||||
"node-sass-tilde-importer": "^1.0.0",
|
"node-sass-tilde-importer": "^1.0.0",
|
||||||
"rancher-website-theme": "https://github.com/rancherlabs/website-theme.git",
|
"rancher-website-theme": "https://github.com/rancherlabs/website-theme.git",
|
||||||
|
"request": "^2.87.0",
|
||||||
"run-sequence": "^2.0.0",
|
"run-sequence": "^2.0.0",
|
||||||
"vinyl-buffer": "^1.0.1",
|
"vinyl-buffer": "^1.0.1",
|
||||||
"vinyl-source-stream": "^2.0.0"
|
"vinyl-source-stream": "^2.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user