-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli.js
40 lines (35 loc) · 1.14 KB
/
cli.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
#!/usr/bin/env node
const cmd = require('commander');
const pkg = require('./package');
const toInt = str => parseInt(str, 10);
cmd
.version(pkg.version)
.usage('[options]')
.option('-d, --db-host <hostname>', 'clickhouse host', '127.0.0.1')
.option('-P, --db-port <port>', 'clickhouse port', toInt, 80)
.option('-a, --db-auth <username:password>', 'clickhouse username and password')
.option('-n, --db-name <database>', 'clickhouse database name', 'taotie')
.option('-H, --http <port>', 'HTTP server port', toInt, 80)
.option('-U, --udp <port>', 'UDP log receiver port', toInt, 514)
.option('-i --interval <second>', 'save logs interval', toInt, 5)
.option('-I --data-skipping-indices', 'enable clickhouse data skipping indices')
.option('-D, --dev', 'development mode')
.parse(process.argv);
if (cmd.dev) {
process.env.NODE_ENV = 'development';
}
const taotie = require('./index');
taotie({
db: {
host: cmd.dbHost,
port: cmd.dbPort,
auth: cmd.dbAuth,
queryOptions: {
database: cmd.dbName,
},
},
http: cmd.http,
udp: cmd.udp,
interval: cmd.interval,
dataSkippingIndices: cmd.dataSkippingIndices,
});