-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.lua
92 lines (73 loc) · 2.26 KB
/
init.lua
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
--[[
Copyright 2012 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
local logging = require('logging')
local debugm = require('debug')
local fmt = require('string').format
local MonitoringAgent = require('./monitoring_agent').MonitoringAgent
local Setup = require('./setup').Setup
local constants = require('./util/constants')
local argv = require("options")
.usage('Usage: ')
.describe("i", "use insecure tls cert")
.describe("i", "insecure")
.describe("e", "entry module")
.describe("x", "check to run")
.describe("s", "state directory path")
.describe("c", "config file path")
.describe("p", "pid file path")
.describe("o", "skip automatic upgrade")
.describe("d", "enable debug logging")
.alias({['o'] = 'no-upgrade'})
.alias({['d'] = 'debug'})
.describe("u", "setup")
.alias({['u'] = 'setup'})
.describe("U", "username")
.alias({['U'] = 'username'})
.describe("K", "apikey")
.alias({['K'] = 'apikey'})
.argv("idonhU:K:e:x:p:c:s:n:k:u")
local Entry = {}
function Entry.run()
if argv.args.d then
logging.set_level(logging.EVERYTHING)
else
logging.set_level(logging.INFO)
end
if argv.args.crash then
return virgo.force_crash()
end
local options = {}
if argv.args.s then
options.stateDirectory = argv.args.s
end
options.configFile = argv.args.c or constants.DEFAULT_CONFIG_PATH
if argv.args.p then
options.pidFile = argv.p
end
if argv.args.i then
options.tls = {
rejectUnauthorized = true,
ca = require('./certs').caCertsDebug
}
end
if argv.args.e then
local mod = require(argv.args.e)
return mod.run(argv.args)
end
local agent = MonitoringAgent:new(options)
if not argv.u then
return agent:start(options)
end
Setup:new(argv, options.configFile, agent):run()
end
return Entry