-
Notifications
You must be signed in to change notification settings - Fork 0
/
base1.js
54 lines (45 loc) · 1021 Bytes
/
base1.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
51
52
53
54
const dns = require('dns');
function dnsSeed (seneca, options, bases, next) {
dns.lookup(
'test',
{
all: true,
family: 4
},
(err, addresses) => {
let bases = [];
if (err) {
throw new Error('dns lookup for base node failed');
}
if (Array.isArray(addresses)) {
bases = addresses.map((address) => {
return address.address;
});
} else {
bases.push(addresses);
}
next(bases);
}
);
}
const config = {
// listen: [{ pin: 'service:user,command:*', model: 'consume', type: 'tcp' }],
port: 39001,
discover: {
rediscover: true,
custom: {
active: true,
find: dnsSeed
}
},
isbase: true,
base: true,
monitor: true
}
config.bases = '127.0.0.1:39000,127.0.0.1:39001'.split(',');
let microwizard;
(async function() {
const { default: Microwizard, transport } = (await import("microwizard"));
microwizard = new Microwizard()
microwizard.use('mesh', config)
})()