-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (37 loc) · 1.02 KB
/
index.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
// index.js - Broker instance
// Copyright 2021 Padi, Inc. All Rights Reserved.
'use strict';
// Imports
const service = require('./src/service.js');
const config = require('./config.json');
// Start services
service.start(config, {
// Command line flags
flags: [
['--host', 'addr', 'Set server host'],
['--port', 'number', 'Set server port'],
['--localhost', null, 'Set to localhost']
],
// Process flag
flag: (flag, value) => {
// What flag?
switch(flag) {
case '--host':
// Set server host
service.set('server', 'host', value);
break;
case '--port':
// Set server port
service.set('server', 'port', value);
break;
case '--localhost':
// Set to localhost
service.set('messages', 'protocol', 'ws');
service.set('messages', 'host', 'localhost');
service.set('messages', 'port', '1881');
service.set('server', 'host', 'localhost');
service.set('server', 'port', '8081');
break;
}
}
});