Authored by 郝肖肖

'risk-erver'

... ... @@ -5,11 +5,17 @@ const zookeeper = require('node-zookeeper-client');
const _createClient = (server) => new Promise((resolve, reject) => {
const client = zookeeper.createClient(server);
let isServerStart = false;
client.once('connected', function () {
resolve(client);
client.once('connected', function (err) {
isServerStart = true;
err ? reject(err) : resolve(client);
});
setTimeout(() => {
!isServerStart && reject({message: 'Failed to authenticate with the server.', code: -1});
}, 5000);
client.connect();
});
... ...