Showing
1 changed file
with
8 additions
and
2 deletions
@@ -5,11 +5,17 @@ const zookeeper = require('node-zookeeper-client'); | @@ -5,11 +5,17 @@ const zookeeper = require('node-zookeeper-client'); | ||
5 | 5 | ||
6 | const _createClient = (server) => new Promise((resolve, reject) => { | 6 | const _createClient = (server) => new Promise((resolve, reject) => { |
7 | const client = zookeeper.createClient(server); | 7 | const client = zookeeper.createClient(server); |
8 | + let isServerStart = false; | ||
8 | 9 | ||
9 | - client.once('connected', function () { | ||
10 | - resolve(client); | 10 | + client.once('connected', function (err) { |
11 | + isServerStart = true; | ||
12 | + err ? reject(err) : resolve(client); | ||
11 | }); | 13 | }); |
12 | 14 | ||
15 | + setTimeout(() => { | ||
16 | + !isServerStart && reject({message: 'Failed to authenticate with the server.', code: -1}); | ||
17 | + }, 5000); | ||
18 | + | ||
13 | client.connect(); | 19 | client.connect(); |
14 | }); | 20 | }); |
15 | 21 |
-
Please register or login to post a comment