-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
50 lines (46 loc) · 1.23 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const readline = require('readline');
const ccm = require('./dist');
const cluster = ccm.createCluster({
clusterConfig: { enable_user_defined_functions: true },
// configureLoopbackAliases: false,
nodes: 2,
startAddress: '127.0.0.4',
jmxPort: 7101,
purge: true,
version: 3.8
// verbose: true,
});
const timeout = (t = 1000) => new Promise(resolve => setTimeout(resolve, t));
cluster
.initialize()
// .then(() => timeout())
.then(() => cluster.populateNodes())
// .then(() => timeout())
.then(() => cluster.configureNodes())
// .then(() => timeout())
.then(() => cluster.start())
// .then(() => timeout())
.then(() => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise((resolve) => {
rl.question('Press [r] to remove, [s] to stop, and enter to leave it up... ', (response) => {
let p = Promise.resolve();
switch (response) {
case 'r':
p = cluster.remove();
break;
case 's':
p = cluster.shutdown();
break;
default:
break;
}
rl.close();
p.then(resolve);
});
});
})
.catch(e => console.log(e));